1、所需環(huán)境
Linux:這里使用CentOS 7.5
MySQL:5.5及以上
PHP:5.2及以上
Apache:也可使用nginx
Git
2、安裝環(huán)境
2.1、 腳本安裝
2.1.1、腳本 install_rhel-derivs.sh
注:可修改執(zhí)行腳本。比如修改相關(guān)軟件版本
2.1.2、腳本安裝內(nèi)容
Apache 2.2、MySQL 5.3、PHP 5.3、Git 1.7 并用git下載phabricator, arcanist, libphutil
2.1.3、腳本下載執(zhí)行
cd /opt
# 下載腳本
wget https://secure.phabricator.com/source/phabricator/browse/master/scripts/install/install_rhel-derivs.sh
# 給執(zhí)行權(quán)限
chmod 755 ./install_rhel-derivs.sh
# 執(zhí)行
./install_rhel-derivs.sh
# 移動phabricator相關(guān)文件到apache的發(fā)布目錄下
mkdir -p /var/www/html/pha/
mv /opt/arcanist /var/www/html/pha/
mv /opt/libphutil /var/www/html/pha/
mv /opt/phabricator /var/www/html/pha/
2.2、自行安裝(這里使用此方式)
推薦這種安裝
注意版本問題
2.2.1、Apache 安裝
# Apache 2.4.6
yum install httpd
# 開放端口
firewall-cmd --zone=public --add-port=80/tcp --permanent
# 重啟防火墻
firewall-cmd --reload
# 啟動
systemctl start httpd
# 查看
httpd -v
2.2.2、MySQL安裝
# 安裝
yum install mysql-server
# 安裝不了,進(jìn)行如下操作
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum install mysql-server
# 啟動
systemctl start mysqld
# 查看
mysql -V
# 登錄
mysql -u root -p
# 修改root登錄密碼
set password for root@localhost = password('******');
# 設(shè)置遠(yuǎn)程訪問
grant all privileges on *.* to 'root'@'%' identified by '******' with grant option;
# 刷新退出
flush privileges;
quit
# 開放端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent
# 重啟防火墻
firewall-cmd --reload
# 修改數(shù)據(jù)庫默認(rèn)編碼
# 進(jìn)入mysql配置文件
vi /etc/my.cnf
# 在下面兩項中添加:
[client]
default_character_set=utf8
[mysqld]
collation_server = utf8_general_ci
character_set_server = utf8
# 重啟
systemctl restart mysqld
2.2.3、PHP安裝
# PHP 5.4
yum -y install php
# 查看
php -v
# php 組件
yum install php-pecl-zendopcache php-devel php-mbstring php-mcrypt php-pear php-common php-ldap php-cli pcre-devel php-iconv php-curl php-pcntl php-gd php-fpm php-bcmatphp-odbc php-process php-snmp php-soap php-pecl-jsonphp-xml php-xmlrpc php-xhprof php-phpoffice-phpexcel php-mhash
# 其他
yum curl curl-devel
# apc
yum install php-pecl-apc php-apc
# apc yum安裝不行,可嘗試如下安裝
# 1)首先要安裝apc的依賴包:
yum install httpd-devel pcre-devel gcc make
# 2)然后使用pecl安裝apc:
pecl install apc
# 3)添加apc擴(kuò)展到配置文件php.ini或apc.ini
vi /etc/php.ini
# 添加如下
[apc]
extension=apc.so
#
vi /etc/php.d/apc.int
# 添加如下
/extension=apc.so
-----------------------------------------------------------
# php 其他安裝方式:
# php7.1
# https://blog.csdn.net/hu_zhe_kan/article/details/79368169
# 注意:Phabricator不支持PHP7.0版本
yum -y install php71w
# php 組件
yum -y install php71w-cli php71w-common php71w-devel php71w-embedded php71w-fpm php71w-gd php71w-mbstring php71w-mysqlnd php71w-opcache php71w-pdo php71w-xml php71w-ldap php71w-odbc php71w-pear php71w-xmlrpc php71w-snmp php71w-soap curl curl-devel php71w-bcmath
#
yum curl curl-devel
# apc
yum install php-pecl-apc
-------------------------------------------------------------
2.2.4、Git
# Git 2.16.5
# yum 默認(rèn)為1.X
# 若yum安裝2.X:https://blog.csdn.net/caimengyuan/article/details/80634752
yum install git
# 查看
git --version
2.2.5、語法高亮
# 語法高亮設(shè)置
yum install python-pygments
2.2.6、git克隆phabricator
# phabricator
mkdir -p /var/www/html/pha/
cd /var/www/html/pha
git clone https://github.com/phacility/libphutil.git
git clone https://github.com/phacility/arcanist.git
git clone https://github.com/phacility/phabricator.git
3、相關(guān)配置
3.1、Apache
# 1、進(jìn)入配置文件
vi /etc/httpd/conf/httpd.conf
# 2、修改或添加如下配置
# DocumentRoot
DocumentRoot "/var/www/html/pha/phabricator/webroot"
# DirectoryIndex 添加index.php
# Apache 2.4 之前版本
DirectoryIndex index.php index.html index.html.var
# Apache 2.4 及其之后版本
DirectoryIndex index.php index.html
# VirtualHost
<VirtualHost *:80>
RewriteEngine on
RewriteRule ^/rsrc/(.) - [L,QSA]
RewriteRule ^/favicon.ico - [L,QSA]
RewriteRule ^(.*)$ /index.php?__path__=$1 [B,L,QSA]
</VirtualHost>
# Directory 加入上述VirtualHost中
# Apache 2.4 之前版本
<Directory /var/www/html/pha/phabricator/webroot/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
# Apache 2.4 及其之后版本
<Directory /var/www/html/pha/phabricator/webroot/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Require all granted
</Directory>
# 3、重啟
systemctl restart httpd
3.2、MySQL
# 進(jìn)入phabricator目錄
cd /var/www/html/pha/phabricator/
# 配置如下,也可在./conf/local/local.json中添加
./bin/config set mysql.host localhost
./bin/config set mysql.port 3306
./bin/config set mysql.user root
./bin/config set mysql.pass ******
# 為phabricator創(chuàng)建mysql相關(guān)數(shù)據(jù)表
./bin/storage upgrade --force
3.3、訪問頁面,進(jìn)行有關(guān)配置
瀏覽器訪問地址:IP訪問即可
3.3.1、注冊管理員
注冊信息:用戶名/密碼/郵箱/
訪問進(jìn)入注冊界面填入上述注冊信息進(jìn)行注冊,然后進(jìn)入主頁面
注:也可用phabricator后臺命令來注冊管理員 ./bin/auth recover <管理員賬號> ...

3.3.2、 添加中文支持
cd ./src/extensions
git clone https://github.com/wanthings/phabricator-zh_CN.git
進(jìn)入頁面進(jìn)行配置


3.3.3、解決相關(guān)issue問題
注:點(diǎn)擊進(jìn)入issue問題, 會有相關(guān)解決方法的提示,一般根據(jù)提示進(jìn)行相關(guān)配置即可解決
1) Authentication Providers Configured(登錄認(rèn)證)
該問題是用戶登錄配置,不解決的話無法正常登錄phabricator,需要設(shè)置授權(quán)方式(認(rèn)證信息),如下配置



退出后可到登陸界面進(jìn)行登錄

2)Phabricator Daemons Are Not Running(開啟守護(hù)線程)
后臺守護(hù)進(jìn)程將會執(zhí)行系統(tǒng)跟蹤、檢測以及郵件收發(fā)等操作。所以該問題應(yīng)該修復(fù),后期如果出現(xiàn)了問題或者刷新的話,可以對它停止、調(diào)試、重啟等操作。特別是在郵件收發(fā)服務(wù)失敗時,應(yīng)該多次重啟這個守護(hù)進(jìn)程。
# 啟動守護(hù)進(jìn)程即可
./bin/phd start
3)腳本安裝環(huán)境時,會出現(xiàn)MySQL 5.3 版本過低,需進(jìn)行升級
# 最好先進(jìn)行備份,再升級
# 升級
more /etc/redhat-release
rpm -Uvh http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
yum -y upgrade mysql
# 重啟
systemctl restart mysqld
4)Missing Repository Local Path(配置本地庫)
該操作執(zhí)行本地代碼庫以及網(wǎng)絡(luò)代碼庫本地保存路徑。系統(tǒng)默認(rèn)使用/var/repo,也可以其他的可用路徑。系統(tǒng)剛安裝完成/var/repo路徑是不存在的,如果使用它的話必須先創(chuàng)建并賦予讀寫執(zhí)行權(quán)限
默認(rèn)倉庫可修改:
./bin/config set repository.default-local-path '/路徑/repo'
創(chuàng)建并賦予倉庫權(quán)限
mkdir /var/repo
chown -R root. /var/tmp/phd
chown -R root. /var/repo
注:不賦予權(quán)限可能導(dǎo)致代碼庫克隆不下來
5)Server Timezone Not Configured(設(shè)置phabricator服務(wù)器的時區(qū))
該問題是設(shè)置服務(wù)器的時區(qū)的。系統(tǒng)很多操作將會產(chǎn)生時間戳保存到數(shù)據(jù)庫或者其他的通信操作,所以應(yīng)該設(shè)定,否則系統(tǒng)默認(rèn)使用格林威治標(biāo)準(zhǔn)時間, 一般為"Asia/Shanghai"
php配置:
# 進(jìn)入php配置文件
vi /etc/php.int
# 修改如下
date.timezone = "Asia/Shanghai"
# 重啟httpd
systemctl resatrt httpd
頁面配置:
點(diǎn)擊此issues問題,點(diǎn)擊 issue Edit phabricator.timezone 進(jìn)入對應(yīng)頁面,在“Value”欄中輸入“Asia/Shanghai”。然后保存設(shè)置即可
6)Large File Storage Not Configured
因為默認(rèn)使用mysql存儲,需要修改對mysql存儲的限制
./bin/config set storage.mysql-engine.max-size 104857600
7) No Sendmail Binary Found(郵件發(fā)送問題)
該問題是郵件收發(fā)服務(wù)問題。系統(tǒng)很多功能后臺會執(zhí)行郵件收發(fā)動作,所以必須配置系統(tǒng)使用的郵件收發(fā)服務(wù)
由于需要郵件收發(fā)服務(wù),所以必須安裝SendMail
SendMail安裝
# 下載SendEmail
wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz
# 解壓安裝
tar -xzvf sendEmail-v1.56.tar.gz -C /usr/local/
mv /usr/local/sendEmail-v1.56 /usr/local/sendemail
ln -s /usr/local/sendemail/sendEmail /usr/sbin/sendmail
# 開放端口
firewall-cmd --zone=public --add-port=25/tcp --permanent
firewall-cmd --zone=public --add-port=465/tcp --permanent
# 重啟防火墻
firewall-cmd --reload
# 發(fā)送郵件測試
sendmail -f efewve@163.com -t efvfrdfv@qq.com -s smtp.163.com -u "郵件主題" -o message-content-type=html -o message-charset=utf8 -efewve@163.com -xp xxxx -m "郵件內(nèi)容"
————————————————————————————————————————————————————————————
# 命令說明:
sendmail:郵件主程序
-f efewve@163.com:發(fā)件人郵箱
-t efvfrdfv@qq.com:收件人郵箱
-s smtp.163.com:發(fā)件人的smtp服務(wù)器地址
-u "郵件主題":郵件的標(biāo)題
-o message-content-type=html:郵件內(nèi)容的格式,html表示它是html格式
-o message-charset=utf8:郵件內(nèi)容編碼
-xu efewve@163.com:發(fā)件人的郵箱賬號
-xp xxxx:發(fā)件人郵箱密碼
-m "郵件內(nèi)容":郵件的具體內(nèi)容
————————————————————————————————————————————————————————————
# 發(fā)送成功提示如下
Feb 02 17:17:30 localhost sendmail[6652]: Email was sent successfully!
# 可能發(fā)送存在的問題:phpmailer error SMTP Error: Could not connect to SMTP host Could not instantiate mail function?
# 可能原因:PHPMailer發(fā)送郵件,出現(xiàn)無法連接host,這是因為fsockopen函數(shù)被禁用,PHPmailer發(fā)送Email依賴此函數(shù)
# 上述原因解決辦法:修改/var/www/html/pha/phabricator/externals/phpmailer下文件,如下:
# 1、修改class.smtp.php文件
# 將如下片段中fsockopen替換成pfsockopen
this->smtp_conn = @fsockopen(host, // the host of the server
port, // the port to use
errno, // error number if any
errstr, // error message if any
tval); // give up after ? secs
# 2、修改class.phpmailer.php文件
# 將如下連個片段中smtp替換成SMTP,或其他地方smtp改為SMTP
switch($this->Mailer) {
case 'sendmail':
return $this->SendmailSend($header, $body);
case 'smtp':
return $this->SmtpSend($header, $body);
default:
return $this->MailSend($header, $body);
}
public function IsSMTP() {
$this->Mailer = 'SMTP';
頁面中配置
config -->core-->mail-->
設(shè)置發(fā)件郵箱:
metamta.default-address-->abcdef@163.com
設(shè)置郵件適配器 :
metamta.mail-adapter -->PhabricatorMailImplementationPHPMailerAdapter
如下圖:

Phabricator中配置
# 發(fā)件郵箱
./bin/config set metamta.default-address abcdef@163.com
# 郵件適配器
./bin/config set metamta.mail-adapter PhabricatorMailImplementationPHPMailerAdapter
# 郵箱相關(guān)配置
./bin/config set phpmailer.mailer smtp
./bin/config set phpmailer.smtp-protocol SSL
./bin/config set phpmailer.smtp-host smtp.163.com
# 注意:此處郵件端口為465,一般為25或465
./bin/config set phpmailer.smtp-port 465
./bin/config set phpmailer.smtp-user abcdef@163com
./bin/config set phpmailer.smtp-password *******
# 測試是否可正常發(fā)送郵件
# 發(fā)送
./bin/mail send-test --to cfeverve@163.com --subject hello <README.md>
# 查看發(fā)送狀態(tài)
./bin/mail list-outbound
# 查看發(fā)送詳情, 以便失敗時排查錯誤
./bin/mail show-outbound --id 25
# 重啟守護(hù)進(jìn)程
./bin/phd
——————————————————————————————————————————————————————————————
# 發(fā)送郵可能報如下錯
*******************************************************************
Using the default of SSL_verify_mode of SSL_VERIFY_NONE for client
is deprecated! Please set SSL_verify_mode to SSL_VERIFY_PEER
possibly with SSL_ca_file|SSL_ca_path for verification.
If you really don't want to verify the certificate and keep the
connection open to Man-In-The-Middle attacks please set
SSL_verify_mode explicitly to SSL_VERIFY_NONE in your application.
*******************************************************************
at /usr/sbin/sendmail line 1906.
invalid SSL_version specified at /usr/share/perl5/vendor_perl/IO/Socket/SSL.pm line 444.
# 原因 centos7.5默認(rèn)是 perl的版本是5.16,centos6.8的是5.10,后來把7的版本換成5.10,就可以正常發(fā)郵件了。
# 解決如下
wget http://www.cpan.org/src/5.0/perl-5.10.0.tar.gz
tar zxf perl-5.10.0.tar.gz
cd perl-5.10.0
./configure.gnu -des -Dprefix=/usr/local/perl
echo $? #返回0,編譯沒問題
make
make test
make install
# 備份原來的Perl
mv /usr/bin/perl /usr/bin/perl.bak
ln -s /usr/local/perl/bin/perl /usr/bin/perl
#查看Perl版本,顯示5.10表示已經(jīng)成功
perl -v
3.4、 配置代碼倉庫訪問方式
3.4.1、配置系統(tǒng)賬戶
1)賬戶介紹
Phabricator有三種賬戶(三種用戶身份;):兩個用于基本運(yùn)行,一個用于配置SSH訪問。
注意:上述賬戶是指Phabricator所運(yùn)行服務(wù)器系統(tǒng)的用戶,不是Phabricator頁面用戶。
三個賬戶分別如下:
www-user:
用于Phabricator Web服務(wù)器運(yùn)行;
大部分情況下,這個賬號已經(jīng)存在了,一般為apache
daemon-user :
daemons (守護(hù)進(jìn)程)運(yùn)行。
是唯一直接與代碼倉庫交互的賬號,其它賬號需要切換到這個賬號身份才能操作代碼倉庫。一般直接用root,因為會需要很多權(quán)限(當(dāng)然這可能不安全)
vcs-user:
用于SSH訪問,
需要創(chuàng)建,一般用于SSH克隆代碼庫
2)設(shè)置或創(chuàng)建賬戶
# daemon-user
./bin/config set phd.user root
# www-user
# 為apache, 系統(tǒng)已有
# vcs-user 創(chuàng)建并設(shè)置
useradd git
usermod -p NP git
usermod -s /bin/sh git
3.4.2、 配置SSH
1)Phabricator中配置
# 顯示ssh clone地址
./bin/config set diffusion.ssh-user git
#
./bin/phd restart
2)配置git賬戶運(yùn)行權(quán)限
# 進(jìn)入 sudoers文件
vi /etc/sudoers
# 添加如下配置
git ALL=(root) SETENV: NOPASSWD: /usr/libexec/git-core/git-http-backend, /usr/bin/git,/usr/bin/git-upload-pack, /usr/bin/git-receive-pack
3)添加并配置腳本
# 添加配置 phabricator-ssh-hook.sh
cp ./resources/sshd/phabricator-ssh-hook.sh /usr/libexec/phabricator-ssh-hook.sh
chmod 755 /usr/libexec/phabricator-ssh-hook.sh
# 進(jìn)入文件
vi /usr/libexec/phabricator-ssh-hook.sh
# 修改如下配置
# ssh帳戶
VCSUSER="git"
# phabricator安裝目錄路徑
ROOT="/var/www/html/pha/phabricator
# 添加配置 sshd_config.phabricator
cp ./resources/sshd/sshd_config.phabricator.example /etc/ssh/sshd_config.phabricator
# 進(jìn)入文件
vi /etc/ssh/sshd_config.phabricator
# 修改如下配置
#
AuthorizedKeysCommand /usr/libexec/phabricator-ssh-hook.sh
# openSSH6.2以下,此字段為AuthorizedKeysCommandRunAs
AuthorizedKeysCommandUser git
AllowUsers git
# 上述文件默認(rèn)端口port字段為2222,則phabricator中配置
./bin/config set diffusion.ssh-port 2222
# 開放端口
firewall-cmd --zone=public --add-port=2222/tcp --permanent
# 重啟防火墻
firewall-cmd --reload
4)啟動phabricator ssh服務(wù)
# 查看是否可以啟動
/usr/sbin/sshd -d -d -d -f /etc/ssh/sshd_config.phabricator
# 正式啟用:此ssh服務(wù)跟系統(tǒng)默認(rèn)ssh不是一個進(jìn)程
/usr/sbin/sshd -f /etc/ssh/sshd_config.phabricator
./bin/phd restart
# 重啟只要執(zhí)行上面相同的命令即可,若要關(guān)閉服務(wù):
ps -ef | grep sshd
kill <id>
5) Phabricator頁面設(shè)置ssh公鑰

3.4.3、 配置http
1)phabricator中配置
# 顯示http clone地址
./bin/config set diffusion.allow-http-auth true
# 添加環(huán)境變量,數(shù)組可放多個
./bin/config set environment.append-paths '["/usr/libexec/git-core"]'
# 重啟守護(hù)進(jìn)程
./bin/phd restart
2)配置apache賬戶運(yùn)行權(quán)限
# 進(jìn)入sudoers文件
vi /etc/sudoers
# 添加如下配置
apache ALL=(root) SETENV: NOPASSWD: /usr/bin/git, /usr/bin/git-upload-pack, /usr/bin/git-receive-pack, /usr/bin/ssh, /usr/libexec/git-core/git-http-backend
注意:git-http-backend:git yum安裝時git-http-backend的路徑:/usr/libexec/git-core/git-http-backend
3)頁面中設(shè)置
config--> all settings-->diffusion.allow-http-auth-->點(diǎn)開,設(shè)置值為:Allow HTTP Basic Auth

設(shè)置git http訪問密碼
-->Settings-->VCS Password-->設(shè)置http訪問密碼

3.4.4 本地Git操作代碼庫
1)頁面創(chuàng)建倉庫
2)git clone url
http:需輸入用戶名/密碼即phabricator用戶名/VCS設(shè)置的密碼
ssh:需要先本地配置phabricator頁面公鑰或上傳公鑰到phabricator頁面即可
- 進(jìn)行Git的其他操作
4、參考文檔
phabricator 官方文檔:
英文:https://secure.phabricator.com/book/phabricator/article/installation_guide/
中文:https://phabricator.webfuns.net/book/phabricator/article/installation_guide/
其他:
https://segmentfault.com/a/1190000011183530
https://yq.aliyun.com/articles/416669
https://blog.csdn.net/a23764996/article/details/53540877
https://www.cnblogs.com/chorulex/p/5381558.html