搭建CodeReivew 工具 Phabricator

简介

现在项目成本投入高了,自然对项目的质量要求也愈来愈高,像发布好还发现明显的 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."(如下图) , 这个坑我不少呀。

posted @ 2017-07-26 21:34  Grissom007  阅读(915)  评论(1编辑  收藏  举报