ひよっこ。

I want to…

phabricatorをインストールしてみた

Posted by hikaruworld : 2012 9月 15

コードレビューツール 6選 どれが最適?で紹介されていたphabricatorに素敵さを感じました。
Ubuntuだとインストールスクリプトが準備されているということで、さくっと?インストールしてみました。

基本的な流れは、こんな感じになりました。
1. ソースの取得と展開
2. 各種設定ファイルの定義
3. セットアップウィザードの実行
4. ログインアカウントの作成

構築した環境は、 lsb_release -aで確認すると以下の通り

No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 12.04.1 LTS
Release: 12.04
Codename: precise

インストールしたphabricatorのhashはeaf7aedb05d01ffab4cceb1bf52cfa084c74d489でした。

なお、virtualbox上に構築されてるUbuntuなので該当のIPアドレスを192.168.56.101とします。

1.アプリケーションの取得とインストール

詳しくはこちらInstallation_Guideを参照しましょう。
今回は/opt/phabricator以下にインストールします。

sudo mkdir /opt/phabricator
sudo chown -R morizou:morizou phabricator/
cd /opt/phabricator
wget http://www.phabricator.com/rsrc/install/install_ubuntu.sh
chmod +x install_ubuntu.sh
./install_ubuntu.sh

以下の様に標準出力にメッセージが流れます。

PHABRICATOR UBUNTU INSTALL SCRIPT
This script will install Phabricator and all of its core dependencies.
Run it from the directory you want to install into.

Phabricator will be installed to: /opt/phabricator.
Press RETURN to continue, or ^C to cancel.

と確認されるのでEnterで。

Testing sudo…
Installing dependencies: git, apache, mysql, php…

パッケージリストを読み込んでいます… 完了

…省略…

35.8 MB のアーカイブを取得する必要があります。
この操作後に追加で 119 MB のディスク容量が消費されます。
続行しますか [Y/n]?

と聞かれるので当然YESで。apt-getとgit cloneで必要な依存モジュールがインストールされます。

取得:1 http://jp.archive.ubuntu.com/ubuntu/ precise/main apache2-mpm-prefork i386 2.2.22-1ubuntu1 [2,400 B]
取得:2 http://jp.archive.ubuntu.com/ubuntu/ precise/main libnet-daemon-perl all 0.48-1 [43.1 kB]

….省略…

Cloning into ‘libphutil’…
remote: Counting objects: 4717, done.
remote: Compressing objects: 100% (1821/1821), done.
remote: Total 4717 (delta 2887), reused 4575 (delta 2752)
Receiving objects: 100% (4717/4717), 1.12 MiB | 169 KiB/s, done.
Resolving deltas: 100% (2887/2887), done.
Cloning into ‘arcanist’…
remote: Counting objects: 6512, done.
remote: Compressing objects: 100% (2644/2644), done.
remote: Total 6512 (delta 4015), reused 6254 (delta 3763)
Receiving objects: 100% (6512/6512), 1.18 MiB | 212 KiB/s, done.
Resolving deltas: 100% (4015/4015), done.
Cloning into ‘phabricator’…
remote: Counting objects: 46594, done.
remote: Compressing objects: 100% (17230/17230), done.
remote: Total 46594 (delta 29339), reused 45607 (delta 28464)
Receiving objects: 100% (46594/46594), 8.07 MiB | 744 KiB/s, done.
Resolving deltas: 100% (29339/29339), done.
Submodule ‘externals/javelin’ (git://github.com/facebook/javelin.git) registered for path ‘externals/javelin’
Cloning into ‘externals/javelin’…
remote: Counting objects: 1814, done.
remote: Compressing objects: 100% (669/669), done.
remote: Total 1814 (delta 1131), reused 1782 (delta 1104)
Receiving objects: 100% (1814/1814), 546.50 KiB | 207 KiB/s, done.
Resolving deltas: 100% (1131/1131), done.
Submodule path ‘externals/javelin’: checked out ‘6ad17a59326690ed11c4b72c506a6218e438cad9’

Install probably worked mostly correctly. Continue with the ‘Configuration Guide’:

http://www.phabricator.com/docs/phabricator/article/Configuration_Guide.html

You can delete any php5-* stuff that’s left over in this directory if you want.

問題なくインストールされると上記の様にログが出力されます。
ちなみにディレクトリ的にはこんな感じになりました。

/opt/phabricator
├── arcanist
├── install_ubuntu.sh
├── libphutil
└── phabricator

注意事項:Proxyが原因でgit cloneに失敗する場合

通常プロキシ環境においてgit clone https://…が通っていても、host名が解決出来ずエラーになってしまいました。
スクリプト自体が、git://プロトコルで定義されている事、
https_proxyの環境設定が伝わらなかった事が原因だったので、
以下のようにスクリプトを修正しました

7a8,10
> export https_proxy=http://proxy.com:80
>
>
62c65
<   git clone git://github.com/facebook/libphutil.git
---
>   git clone https://github.com/facebook/libphutil.git
69c72
<   git clone git://github.com/facebook/arcanist.git
---
>   git clone https://github.com/facebook/arcanist.git
76c79
<   git clone git://github.com/facebook/phabricator.git
---
>   git clone https://github.com/facebook/phabricator.git
79a83,85
>
> sudo sed -i s/git:/https:/g phabricator/.gitmodules
> sudo sed -i s/git:/https:/g phabricator/.git/config

2.アプリケーションの設定

無事インストール?が終わったら、設定を行っていきます。
ここからの説明はConfiguration_Guideに書かれているのでその手順に従います。

2.1設定ファイルを作成

myconfig.conf.phpというファイルを新規に作成します。

mkdir -p /opt/phabricator/phabricator/conf/custom/
cd /opt/phabricator/phabricator/conf/custom/
touch myconfig.conf.php

ファイル設定に関しては設定ガイドのサンプルを修正します。
phabricator.base-urimysql.*関連の修正と、
メールを送信しない場合はmetamta.mail-adapterを新規に定義します。
というか、metamta.mail-adapterの設定しないとセットアップ中に失敗しますのでご注意を(詳細は下記参照)。

こんな感じに設定しています。

<?php

return array(

  // Important! This will put Phabricator into setup mode to help you
  // configure things.
  'phabricator.setup' => true,

  // This will be the base domain for your install, and must be configured.
  // Use "https://" if you have SSL. See below for some notes.
  'phabricator.base-uri' => 'http://192.168.56.101',

  // Connection information for MySQL.
  'mysql.host' => 'localhost',
  'mysql.user' => 'root',
  'mysql.pass' => 'mysqlrootpassword',

  // Basic email domain configuration.
  'metamta.default-address' => 'noreply@phabricator.example.com',
  'metamta.domain'          => 'phabricator.example.com',
  'metamta.mail-adapter'    => 'PhabricatorMailImplementationTestAdapter'

  // NOTE: Check default.conf.php for detailed explanations of all the
  // configuration options, including these.

) + phabricator_read_config_file('production');
?>

2.2. 環境変数の設定

PHABRICATOR_ENVの環境変数を設定が必要なので、.bashrcPHABRICATOR_ENV=custom/myconfigを追記しておきます。

echo "export PHABRICATOR_ENV=custom/myconfig" >> ~/.bashrc
source ~/.bashrc

2.3. Apache2の設定

PHPさんなので、apache2で起動設定を行います。
設定ガイドではVirtualHostで設定していますが、面倒なのでdefault(http://192.168.56.101/)で動くようにします。
/etc/apache2/sites-available/defaultを以下のように修正します。

<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        ServerName localhost.com

        #DocumentRoot /var/www
        DocumentRoot /opt/phabricator/phabricator/webroot

        RewriteEngine on
        RewriteRule ^/rsrc/(.*)     -                       [L,QSA]
        RewriteRule ^/favicon.ico   -                       [L,QSA]
        RewriteRule ^(.*)$          /index.php?__path__=$1  [B,L,QSA]

        SetEnv PHABRICATOR_ENV custom/myconfig

        # 以下省略....

再起動します。

sudo /etc/init.d/apache2 restart

注意事項:rewirteがインストールされていない

起動時にrewriteを導入していないと、以下のエラーになります。

Invalid command ‘RewriteEngine’, perhaps misspelled or defined by a module not included in the server configuration
Action ‘configtest’ failed.
The Apache error log may have more information.
…fail!

以下のコマンドでインストールします。

sudo a2enmod rewrite

こんな感じでインストールされました。

Enabling module rewrite.
To activate the new configuration, you need to run:
service apache2 restart

3. Setupウィザードを実行

http://192.168.56.101/にアクセスして、Setupを行います。
色々設定される途中で、エラーが出るので修正していきましょう。

エラーが出ないように修正をして、以下のように表示されたらとりあえずOKです。

>>> SUCCESS! —————————————————————–

Congratulations! Your setup seems mostly correct, or at least fairly reasonable.

*** NEXT STEP ***
Edit your configuration file (conf/custom/myconfig.conf.php) and remove the ‘phabricator.setup’ line to finish installation.

修正が完了、myconfig.conf.phpのphabricator.setupfalseに設定しておきます。

注意事項:timezoneの設定

<<< *** FAILURE! *** >>>
Setup failure! Your configuration fails to specify a server timezone. Either set ‘date.timezone’ in your php.ini or ‘phabricator.timezone’ in your Phabricator configuration. See the PHP documentation for a list of supported timezones:

/etc/php5/apache2/php.initimezoneの設定もれなので追加してapacheを再起動します。

date.timezone = 'Asia/Tokyo'

注意事項:ドメインの問題

<<< *** FAILURE! *** >>>
You must host Phabricator on a domain that contains a dot (‘.’). The current domain, ‘localhost’, does not have a dot, so some browsers will not set cookies on it. For instance, ‘http://example.com/ is OK, but ‘http://example/&#8217; won’t work. If you are using localhost, create an entry in the hosts file like ‘127.0.0.1 example.com’, and access the localhost with ‘http://example.com/&#8217;.

phabricator.base-urihttp://localhostなどのようにドットを持たないURLを指定しているとエラーになってしまいます。
localhost.comなど.を含むURLにする必要があります。

# となるとlocalhostで単純に出来ないのでlocalhost.comとか作って/etc/hostsを弄ったりするはめに…

注意事項:SQLの更新

<<< *** FAILURE! *** >>>
Setup failure! You haven’t run ‘bin/storage upgrade’. See this article for instructions:

自分の環境では初期セットアップでも出た場合と出ない場合がありましたが…。
設定ガイドに従って以下を実行してstrageを初期化します。

prepro:/opt/phabricator/$ ./bin/storage upgrade

注意事項:メール設定

<<< *** FAILURE! *** >>>
Setup failure! You don’t have a ‘sendmail’ binary on this system but outbound email is configured to use sendmail. Install an MTA (like sendmail, qmail or postfix) or use a different outbound mail configuration. See this guide for configuring outbound email:

メール設定が行われていないときに発生します。
必要に応じて任意のメールサーバーを設定します。
ここではとりあえず無効化の設定を myconfig.config.phpに設定を行っています。
詳しくはConfiguring_Outbound_Emailを参考にしてください。

MySQLのタイムアウト設定

*** NOTE: Your MySQL connect timeout is very high (60 seconds). Consider reducing it
to 5 or below by setting ‘mysql.connect_timeout’ in your php.ini.

タイムアウトが長すぎると警告されているので5秒辺りにphp.iniを修正します。

mysql.connect_timeout = 5

注意事項:セットアップ完了で初期遷移後のエラー

This install of Phabricator is configured as ‘localhost.com’ but you are accessing it via ‘192.168.56.101’. Access Phabricator via the primary configured domain.

ドアクセス質得るドメインとmyconfig.config.php上で定義したphabricator.base-uriが違うとこのエラーが出ます。同じドメインに設定しておきましょう。

4.アカウントの作成

http://192.168.56.101/へ遷移すると、アカウントの入力を求められます。
phabricator自体はFaebookやGoogleへのOAuthをサポートしていますが、デフォルトではuserId/Passwordの認証のみになります。
管理者権限があればWEBからアカウントの制御を行えますが、初期ユーザはCLIで作成する必要があります。

prepro@/opt/phabricator/phabricator$ bin/accountadmin 

でウィザードが起動して新規ユーザを作成します。

アカウント関連に関してはConfiguring_Accounts_and_Registrationを参照してください。

以上で、環境構築は完了です。
これで起動して確認する事が可能ですが、次回はその他の設定を行います。

2件のフィードバック to “phabricatorをインストールしてみた”

  1. […] phabricatorをインストールしてみた « ひよっこ Phabricatorセットアップした時のメモ – ごろねこ日記 […]

  2. はじめまして。続きをお願いします。
    Differentialの最初のdiffってどの様に作ってますか?
    やはり、cuiでarcを使った方がいいのですかね

コメントを残す