拙网论坛

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 257|回复: 0

Phabricator部署

[复制链接]

949

主题

1001

帖子

3736

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
3736
发表于 2019-1-24 18:24:58 | 显示全部楼层 |阅读模式
概述Phabricator是由facebook开发的一套集任务追踪、文档、代码库、文件存储等功能于一体的开源软件,功能较为完善,对于创业公司、小公司乃至大公司而言都是一个非常好用的管理工具,本篇文章便对phabricator的部署方法作一些介绍。
部署Phabricator由php语言编写并通过常用的web server来提供服务,大多数流行的linux操作系统应该都是可以用于部署的,本篇使用的是Centos7。
PHP安装软件包安装Phabricator要求必须使用PHP5,推荐使用5.6版本,为此先将remi库加入到yum的repo中,这里直接从网上找了一个包下载安装,有些系统也可以直接通过yum安装。
wget http://rpms.famillecollet.com/enterprise/remi-release-7.rpmrpm -Uvh remi-release-7.rpm然后启用remi库中的php56子库,找到enable值并设置成1。
vim /etc/yum.repos.d/remi.repo[remi-php56]enabled=1接下来就可以安装一系列依赖的php软件包了。
yum install php php-common php-mbstring php-iconv php-mysql php-curl php-pcntl php-gd php-apc php-xhprof pcre-devel php-pear php-fpm php-pecl-zendopcache python-pygments php-phpoffice-phpexcel配置用户由于一般git服务器都是通过git这个用户来提供服务的,所以这里我们也先创建一个git用户,系统默认会将同名的组git也创建好,并且将用户git加入到了组git中。
useradd git接下来把启动php-fpm的用户和组也都设置成git。
vim /etc/php-fpm.d/www.confuser = gitgroup = git安装web服务器这里选择了使用nginx来提供web服务,先安装nginx,然后按照phabricator安装文档上的说明修改配置文件。
yum install nginxvim /etc/nginx/nginx.confuser git git;worker_processes 4;error_log /var/log/nginx/error.log;pid /run/nginx.pid;include /usr/share/nginx/modules/*.conf;events {    worker_connections 1024;}http {    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '                      '$status $body_bytes_sent "$http_referer" '                      '"$http_user_agent" "$http_x_forwarded_for"';    access_log  /var/log/nginx/access.log  main;    sendfile            on;    tcp_nopush          on;    tcp_nodelay         on;    keepalive_timeout   65;    types_hash_max_size 2048;    include             /etc/nginx/mime.types;    default_type        application/octet-stream;    include /etc/nginx/conf.d/*.conf;    server {        server_name phabricator.aorise.org;        root        /home/git/phabricator/webroot;        location / {            index   index.php;            rewrite ^/(.*)$ /index.php?__path__=/$1 last;        }        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;        }    }}Phabricator安装代码获取phabricator是github上的一个开源项目,所以需要先安装git。
yum install git然后切换到我们刚才创建的git用户,在主目录下将phabricator的几个代码库都clone下来。
su git -cd ~git clone https://github.com/phacility/libphutil.gitgit clone https://github.com/phacility/arcanist.gitgit clone https://github.com/phacility/phabricator.git数据库配置Phabricator使用一个mysql数据库来存储元数据,可以选择一个公共的mysql服务,这里选择了本地部署。首先安装mysql并且启动,然后初始化。
yum install mariadb-server mariadb-clientsystemctl enable mariadbsystemctl start mariadbmysql_secure_installation接下来配置phabricator使用本地的mysql,创建一个定制化的配置文件,注意配置文件后缀必须使用.conf.php
cd phabricatormkdir conf/customvim conf/custom/mysql.conf.php<?phpreturn array(  'mysql.host' => 'localhost',  'mysql.port' => '3306',  'mysql.user' => 'root',  'mysql.pass' => '',);将配置文件加入到phabricator的配置中,这里省略后缀。
echo custom/mysql > conf/local/ENVIRONMENT最后让phabriator进行初始化。
./bin/storage upgrade启动服务现在phabricator已经配置好了,启动web服务器就可以使用了。
systemctl start nginxsystemctl start php-fpmsystemctl enable nginxsystemctl enable php-fpm然后通过浏览器打开部署phabricator的服务器地址即可。刚进去的时候会有许多warning警告,一般都是配置不完美造成的,根据提示修改配置文件即可。
代码库配置因为代码库的设置要更加繁琐和特别,所以phabriator不会自动安装好代码库,还需要一些人工的操作。
配置用户官方文档推荐使用几个不同的用户来实现不同的功能,这里比较偷懒,直接用刚才创建的git用户来完成所有功能好了,先给予git用户所有的sudo权限。
vim /etc/sudoersgit  ALL=(ALL)       NOPASSWD: ALL然后给git用户一个shell界面,将shadow文件中git用户的!!替换成NP。
vim /etc/shadowgit:NP:17136:0:99999:7:::还要在/etc/passwd中确保git用户是有shell登录界面的。
vim /etc/passwdgit:x:1000:1000::/home/git:/bin/bash配置phabricator然后设置phabricator来使用这个用户,并且指定代码库的端口,因为22号端口已经被服务器的ssh服务使用了,所以这里使用2222号端口。
su git -cd /home/git/phabricator./bin/config set phd.user git./bin/config set diffusion.ssh-user git./bin/config set diffusion.ssh-port 2222开启ssh服务最后开启代码库的ssh服务,phabricator已经给出了样例文件,复制到一个常用的地方然后将文件中的用户和路径修改成实际的值就行了。
cp /home/git/phabricator/resources/sshd/phabricator-ssh-hook.sh /usr/libexec/phabricator-ssh-hook.shvim /usr/libexec/phabricator-ssh-hook.shVCSUSER="git"ROOT="/home/git/phabricator"cp /home/git/phabricator/resources/sshd/sshd_config.phabricator.example /etc/ssh/sshd_config.phabricatorvim /etc/ssh/sshd_config.phabricatorAuthorizedKeysCommandUser gitAllowUsers git启动服务。
/sbin/sshd -f /etc/ssh/sshd_config.phabricator其他Phabricator的code review(代码评审)功能在另外一个单独的库arcanist中,并且是可以直接使用的,唯一要注意的是,需要给nginx的路径配置上足够的访问权限,不然会报错。
chmod +x  /var/lib/nginxchmod +x  /var/lib/nginx/tmpchmod +x  /var/lib/nginx/tmp/client_body参考资料


作者:胖头鱼战士
链接:https://www.jianshu.com/p/7e64544ce3c2
來源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|抱朴守拙BBS

GMT+8, 2025-5-26 00:58 , Processed in 0.198564 second(s), 18 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表