Google+ Followers

2016年1月2日 星期六

[PHP] 架設 Phabricator - Open Source tools code for review, task management, and project communication @ Ubuntu 14.04

這原本是 Facebook 內部的工具,負責開發的工程師離開 FB 後成立公司來維護它,我對他的感覺就像 Redmine 這類工具。第一次接觸是在 2015 年秋天,但直到年底我才自己架設它,其實過程不會很複雜,但不是 apt-get 就能安裝完的,多少還是筆記一下吧。此外,想要快速把玩可以試試官方提供的 script - install_ubuntu.sh ,更多安裝簡介:Installation Guide

這邊只簡單紀錄自己安裝的過程,其中 MySQL DB server 採用 AWS RDS,而 web server 使用 nginx 跟 php5-fpm:

$ cat /etc/apt/sources.list.d/nginx_org_packages_ubuntu.list
deb http://nginx.org/packages/ubuntu/ trusty nginx
deb-src http://nginx.org/packages/ubuntu/ trusty nginx
$ wget -O - http://nginx.org/keys/nginx_signing.key | sudo apt-key add -
$ sudo apt-get -qq update && sudo apt-get install git dpkg-dev php5 php5-mysql php5-gd php5-dev php5-curl php-apc php5-cli php5-json php5-fpm
$ sudo apt-get install nginx
$ lsb_release -a
No LSB modules are available.
Distributor ID:    Ubuntu
Description:    Ubuntu 14.04.2 LTS
Release:    14.04
Codename:    trusty
$ php -v
PHP 5.5.9-1ubuntu4.14 (cli) (built: Oct 28 2015 01:34:46)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
    with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies

$ mkdir /opt && cd /opt
$ git clone https://github.com/phacility/libphutil.git
$ git clone https://github.com/phacility/arcanist.git
$ git clone https://github.com/phacility/phabricator.git


設定 https web server & php 環境:

$ cat /etc/nginx/conf.d/phabricator.conf
server {
listen       443;
server_name  localhost;
client_max_body_size 8M;

location / {
root   /opt/phabricator/webroot;
index  index.php;
rewrite ^/(.*)$ /index.php?__path__=/$1 last;
}
location = /favicon.ico {
try_files $uri =204;
}
location /index.php {
root "/opt/phabricator/webroot";
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
ssl on;
ssl_certificate /etc/ssl/nginx/server.crt ;
ssl_certificate_key /etc/ssl/nginx/server.key ;
}

$ cat /etc/nginx/nginx.conf
user www-data;
...

$ cat /etc/php5/fpm/pool.d/www.conf
user = www-data
group = www-data
listen = /var/run/php5-fpm.sock
listen.owner = www-data
listen.group = www-data
...

$ cat /etc/php5/fpm/php.ini
upload_max_filesize = 60M
memory_limit = 512M
post_max_size = 60M
date.timezone = Asia/Taipei
opcache.validate_timestamps=false
...


設定 Phabricator 部分:

$ sudo /opt/phabricator/bin/config set mysql.host server-name.ap-northeast-1.rds.amazonaws.com
$ sudo /opt/phabricator/bin/config set mysql.user root
$ sudo /opt/phabricator/bin/config set mysql.pass password
$ sudo /opt/phabricator/bin/storage upgrade

Fix these schema issues? [y/N] Y
Fixing schema issues...
Done.                                                                      
Completed fixing all schema issues.

$ sudo /opt/phabricator/bin/config set phabricator.base-uri 'https://my-domain-name/'
$ sudo /opt/phabricator/bin/config set security.alternate-file-domain https://my-domain-name/
$ sudo /opt/phabricator/bin/config set phpmailer.smtp-user my-smtp-user
$ sudo /opt/phabricator/bin/config set phpmailer.smtp-password my-smtp-password
$ sudo /opt/phabricator/bin/config set phpmailer.smtp-port 25
$ sudo /opt/phabricator/bin/config set phpmailer.smtp-host my-domain-name
$ sudo /opt/phabricator/bin/phd start
$ cat /etc/rc.local
sudo /opt/phabricator/bin/phd start
$ sudo mkdir /var/repo && sudo chown www-data /var/repo
$ cat /opt/phabricator/conf/local/local.json
{
  "phpmailer.smtp-user": "my-smtp-user",
  "phpmailer.smtp-password": "my-smtp-password",
  "phpmailer.smtp-port": 25,
  "phpmailer.smtp-host": "my-domain-name",
  "security.alternate-file-domain": "https://my-domain-name/",
  "phabricator.base-uri": "https://my-domain-name/",
  "mysql.pass": "password",
  "mysql.user": "root",
  "mysql.host": "server-name.ap-northeast-1.rds.amazonaws.com"
}


剩下的可以從網頁上設定,網頁管理做得很不錯的,例如 metamta.default-address、metamta.domain 等,有些 issue 是 MySQL DB server 的,只是 AWS RDB 並不能修改。整體上架設還算輕鬆啦,唯一的缺點是在 DB server 內會開很多資料庫,建議可以專門用一個 DB server 來維護。

1 則留言:

  1. 您好,我有做了一個 Phabricator 繁體中文的語系在 https://github.com/cwlin0416/phabricator-zh_hant/,希望能夠給您一些幫助,如果可以的也希望您能協助翻譯。

    回覆刪除