Skip to content

Instantly share code, notes, and snippets.

@taichi
Last active February 12, 2016 06:08
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save taichi/4951276 to your computer and use it in GitHub Desktop.
Save taichi/4951276 to your computer and use it in GitHub Desktop.
phabricator を ubuntu12.04.01 LTS にインストールした。(2013/02)

phabricator を ubuntu12.04.01 LTS にインストールした。(2013/02)

参考資料

事前準備

Distributor ID: Ubuntu
Description:    Ubuntu 12.04.1 LTS
Release:        12.04
Codename:       precise
  • /etc/environment に HTTPプロキシの設定を追加。
http_proxy=http://proxy.example.co.jp:8000
https_proxy=http://proxy.example..co.jp:8000
  • 専用ユーザの追加
sudo adduser phabricator
sudo usermod -aG sudo phabricator
su - phabricator

シェルスクリプトによる自動インストール

wget http://www.phabricator.com/rsrc/install/install_ubuntu.sh
sed -e "s/git:/https:/g" install_ubuntu.sh > install.sh
chmod u+x install.sh
./install.sh

Webサーバの設定

sudo vi /etc/apache2/sites-available/phabricator
<VirtualHost *:80>
  ServerName phabricator.example.co.jp
  DocumentRoot /home/phabricator/phabricator/webroot
  RewriteEngine on
  RewriteRule ^/rsrc/(.*)     -                       [L,QSA]
  RewriteRule ^/favicon.ico   -                       [L,QSA]
  RewriteRule ^(.*)$          /index.php?__path__=$1  [B,L,QSA]
</VirtualHost>

サーバ名に.(ドット)が入っていないとクッキーが設定出来ない為、適切に動作しないので注意。
面倒ならIPアドレスにしておくと良い。

  • サイトの設定を有効化、併せてデフォルトの設定を無効化
sudo ln -s /etc/apache2/sites-available/phabricator /etc/apache2/sites-enabled/phabricator
sudo rm /etc/apache2/sites-enabled/000-default

設定ファイルの記述

  • phabricatorの設定ファイルを作る
mkdir -p /home/phabricator/phabricator/conf/custom
vi /home/phabricator/phabricator/conf/custom/base.conf.php
<?php
return array(
  'mysql.pass' => 'mysqlpassword'
  'phabricator.base-uri' => 'http://phabricator.example.co.jp',
  'phabricator.timezone'        => 'Asia/Tokyo',

  'metamta.default-address'     => 'noreply@example.co.jp',
  'metamta.domain'              => 'example.co.jp',
  'metamta.mail-adapter'        => 'PhabricatorMailImplementationPHPMailerAdapter',

  'phpmailer.smtp-host'         =>  'smtp.example.co.jp',
  'phpmailer.smtp-port'         =>  25,
  'phpmailer.smtp-user'         =>  '',
  'phpmailer.smtp-password'     =>  ''
) + phabricator_read_config_file('production');
  • 設定ファイルを切替える為のファイルに書き込む。このファイルには、phabricator/conf/ からの相対パスを記述する。
echo custom/base > /home/phabricator/phabricator/conf/local/ENVIRONMENT
  • Apache2の再起動
sudo /etc/init.d/apache2 restart
  • ストレージのアップグレード
cd /home/phabricator/phabricator
./bin/storage upgrade

設定がうまくいっていればログイン画面が出力される。
設定が足りなければエラーメッセージが出力されるので適宜対応する。

アカウントの設定

管理者権限を持つユーザを作成する。

cd /home/phabricator/phabricator
./bin/accountadmin

LDAPを使った認証

  • php5 のLDAPサポートをインストール
sudo apt-get install php5-ldap
vi /home/phabricator/phabricator/conf/custom/ldap.conf.php
<?php
return array(
  'ldap.auth-enabled' => true,
  'ldap.hostname' => 'ldap.example.co.jp',
  'ldap.base_dn'  => 'o=ldap,o=example-g,dc=example,dc=co,dc=jp',
  'ldap.search-first' => true,
  'ldap.username-attribute' => 'uid',
  'ldap.search_attribute' => 'uid',
  'ldap.real_name_attributes' => array('cn'),
) + phabricator_read_config_file('custom/base');

標準的にはldap_bindによって認証する為、base_dnに指定したノードにユーザIDを含むオブジェクトがエントリされていなければならない。
それを避ける為に、ldap.search-firstフラグを設定し認証対象となるユーザの厳密なDNを予め取得する様指示している。
これによって、ldap.base_dnにはある程度浅い階層へのクエリを記述するだけで認証処理を行う事が出来る。
Active Directoryへの接続についてはソースコードを確認する方が手っ取り早い。

  • 現在のアクティブな設定ファイルをLDAP用のデータが追記されたものに変更する。
echo custom/ldap > /home/phabricator/phabricator/conf/local/ENVIRONMENT

コードリポジトリの設定

  • Diffusion User Guide

  • デーモンが管理用に利用するディレクトリの権限を変更する。

sudo usermod -aG www-data phabricator
sudo chmod g+w -R /var/tmp/phd
  • リポジトリを監視するデーモンの起動
cd /home/phabricator/phabricator
./bin/phd start
  • svn をインストール
sudo apt-get install subversion
  • ファイル名に2byte文字を使っている際に化け無いように設定変更
git config --global core.quotepath false
  • ファイル名に2byte文字が含まれていてもシェルコマンド実行前のescapeshellargに2byte文字が消去されない様にする。
    中盤部分にシステムデフォルトのロケールを使う設定があるので行頭の#を削除する。
sudo vi /etc/apache2/envvars 


## The locale used by some modules like mod_dav
export LANG=C
## Uncomment the following line to use the system default locale instead:
. /etc/default/locale

export LANG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment