文章出處

簡介

現在項目成本投入高了,自然對項目的質量要求也愈來愈高,像發布好還發現明顯的 bug,或性能低下這種問題已不能接受。
由于產品的質量和代碼質量密切相關,而開發團隊里并不是每個人都是大神,大家的經驗能力都有分水嶺,當一起協作開發項目,為了保持一致的代碼風格,保證高質量的代碼,代碼審查變得愈加重要。最近一直在找好用的代碼審查工具,網上很多介紹了 (Phabricator)[https://www.phacility.com/] , 而且它還是以前 facebook 開發并且還在使用的代碼審查工具,網上了解了下,決定先用它試手。

安裝

phabricator 用 php + mysql 開發的,運行環境可以用 lamp, 也可以用 lnmp, 我用了 lnmp,操作系統是 centos7。如何搭建 運行環境,網上很多資料,就不重復了,主要記錄下我安裝 phabricator 的過程。

1. 下載 phabricator 源碼
git clone https://github.com/phacility/phabricator.git
2. 配置虛擬目錄

nginx 或 apache 的虛擬服務器的路徑要指向 phabricator下的 webroot目錄,參考我的 nginx 配置

server {
  listen 80;
  server_name <your domain>;
  #access_log /data/wwwlogs/phabricator.easymylife.cn_nginx.log combined;
  #index index.html index.htm index.php;
  root /data/wwwroot/phabricator.easymylife.cn/phabricator/webroot;

  # include /usr/local/nginx/conf/rewrite/wordpress.conf;
  location / {
    index index.php;
    rewrite ^/(.*)$ /index.php?__path__=/$1 last;
  }

  location ~ [^/]\.php(/|$) {
    #fastcgi_pass remote_php_ip:9000;
    fastcgi_pass unix:/dev/shm/php-cgi.sock;
    fastcgi_index index.php;
    include fastcgi.conf;
  }

  location /index.php {
    fastcgi_pass   localhost:9000;
    fastcgi_index   index.php;

    #required if PHP was built with --enable-force-cgi-redirect
    fastcgi_param  REDIRECT_STATUS    200;

    #variables to make the $_SERVER populate in PHP
    fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
    fastcgi_param  QUERY_STRING       $query_string;
    fastcgi_param  REQUEST_METHOD     $request_method;
    fastcgi_param  CONTENT_TYPE       $content_type;
    fastcgi_param  CONTENT_LENGTH     $content_length;

    fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;

    fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
    fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;

    fastcgi_param  REMOTE_ADDR        $remote_addr;
  }
}

其中上面的

  location ~ [^/]\.php(/|$) {
    #fastcgi_pass remote_php_ip:9000;
    fastcgi_pass unix:/dev/shm/php-cgi.sock;
    fastcgi_index index.php;
    include fastcgi.conf;
  }

不能少,phabricator 官網的配置是沒有這段的,會出現 nginx 502 的錯誤。

3. 配置數據庫

phabricator/ $ ./bin/storage set mysql.host localhost
phabricator/ $ ./bin/storage set mysql.user <your mysql username>
phabricator/ $ ./bin/storage set mysql.pass <your mysql password>
phabricator/ $ ./bin/storage upgrade

然后登陸數據庫,就可看到生成了好多 phabricator 作前綴的數據庫

4. 登陸 phabricator

然后登陸到你為phabricator 配置的域名,可看到配置 admin 的頁面。

配置 git repository 的坑

  1. 創建 repository;
  2. 配置 url;
  3. 設置該 url git 的登陸授權;
  4. 激活 repository;
  5. 查看 repository 的 status;
  6. 運行 phd 守護線程: phd 在 phabricator/bin/ 目錄下, 把它添加到 export 中(.bash_profile), 然后 bash phd start;
  7. 創建 /var/repo 目錄;
  8. 設置 bas-uri: bash phabricator/ $ ./bin/storage phabricator.base-uri 'http://your domain/';

如果第 8 步少了, 在 repository 的 status 會一直處在 "No Working Copy Yet Waiting for daemons to build a working copy."(如下圖) , 這個坑我不少呀。


文章列表


不含病毒。www.avast.com
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 大師兄 的頭像
    大師兄

    IT工程師數位筆記本

    大師兄 發表在 痞客邦 留言(0) 人氣()