Phabricator 是facebook開發的一套代碼審核工具,基於PHP和Mysql開發。
准備工作:
系統:Linux CentOS7
環境:
- Apache(或nginx,或lighttpd):需要Apache 2.2.7以上版本。
- MySQL:MySQL必需
- PHP:需要PHP5.2以上版本
- Phabricator:phabricator安裝包
安裝
-
修改ip地址(可忽略)
vi /etc/sysconfig/network-scripts/ifcfg-ethx
注:
1.進入network-scripts后自己看一下ifcfg-ethx的名稱再進行修改
2.如果是虛擬機的linux最好把網絡連接方式設為橋接模式
BOOTPROTO=static #選項為static,dhcp或bootp,分別對應靜態指定的 ip地址,通過dhcp協議獲得的ip地址,通過bootp協議獲得的ip地址
IPADDR=192.168.116.5 #這個為靜態IP地址
GATEWAY=192.168.116.1 #默認網關
NETMASK=255.255.255.0 #子網掩碼
DNS1=218.85.157.99 #DNS配置
-
安裝Apache
關閉firewall:(關閉防火牆)
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall開機啟動
firewall-cmd --state #查看默認防火牆狀態(關閉后顯示notrunning,開啟后顯示running)
運行命令:yun install httpd
現在打開http://192.168.116.4地址,看看有沒有Apache的默認頁面出來了?如果有就對了。
-
安裝mysql
下載mysql的repo源
$ wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
安裝mysql-community-release-el7-5.noarch.rpm包
$ sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm
安裝這個包后,會獲得兩個mysql的yum repo源:/etc/yum.repos.d/mysql-community.repo,/etc/yum.repos.d/mysql-community-source.repo。
- 安裝mysql
$ sudo yum install mysql-server
根據步驟安裝就可以了,不過安裝完成后,沒有密碼,需要重置密碼。
- 重置密碼重>置密碼前,首先要登錄
$ mysql -u root
登錄時有可能報這樣的錯:ERROR 2002 (HY000): Can‘t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock‘ (2),原因是/var/lib/mysql的訪問權限問題。下面的命令把/var/lib/mysql的擁有者改為當前用戶:
'$ sudo chown -R openscanner:openscanner /var/lib/mysql'
然后,重啟服務:
$ service mysqld restart
接下來登錄重置密碼:
$ mysql -u root
mysql > use mysql;mysql > update user set password=password(‘123456‘) where user=‘root‘;mysql > exit;
錯誤信息
- 錯誤信息:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
解決方法:打開/etc/my.cnf,看看里面配置的socket位置是什么目錄。“socket=/var/lib/mysql/mysql.sock”
路徑和“/tmp/mysql.sock”不一致。建立一個軟連接:ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
-
安裝PHP
yum install php php-devel
重啟apache使php生效
/etc/init.d/httpd restart
此時可以在目錄:/var/www/html/下建立一個index.hph文件
代碼:
<?php phpinfo(); ?>
然后訪問這個文件,就能看到PHP的一些信息,index.php
安裝php的擴展(可不裝)
yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc
-
安裝Phabricator
#######把centos版的phabricator安裝腳本下載到opt目錄並安裝
cd /opt
下載 https://secure.phabricator.com/source/phabricator/browse/master/scripts/install/ 頁面的三個文件
install_rhel-derivs.sh:wget https://p.phcdn.net/file/data/@secure/q5leodur5raca77mplfy/PHID-FILE-3xzyr2upmwbslnms7lgb/install_rhel-derivs.sh
install_ubuntu.sh:
wget https://p.phcdn.net/file/data/@secure/hoqul6hmowgimbo5oklh/PHID-FILE-jiplxc5x72gmpd3pqw2t/install_ubuntu.sh
update_phabricator.sh:
wget https://p.phcdn.net/file/data/@secure/ajyfdzpe3ymmnm3imogd/PHID-FILE-kujsi3om7abpuc6frgzd/update_phabricator.sh
chmod 777 install_rhel-derivs.sh
./install_rhel-derivs.sh
#######安裝必要插件
yum -y install pcre-devel
yum -y install php-pear
yum -y install pecl(發現不裝這個也沒事)
yum -y install apc(發現不裝這個也沒事)
#######把這些文件移動到apache的DocumentRoot下
mv /opt/arcanist /var/www/html
mv /opt/libphutil /var/www/html
mv /opt/phabricator /var/www/html
#######關門防火牆和selinux
/etc/init.d/iptables stop
setenforce 0
chkconfig iptables off
im /etc/selinux/config
This file controls the state of SELinux on the system.
SELINUX= can take one of these three values:
enforcing - SELinux security policy is enforced.
permissive - SELinux prints warnings instead of enforcing.
disabled - No SELinux policy is loaded.
SELINUX=disabled
SELINUXTYPE= can take one of these two values:
targeted - Targeted processes are protected,
mls - Multi Level Security protection.
SELINUXTYPE=targeted
#######修改
vim /etc/httpd/conf/httpd.conf以下幾點
#######設置DocumentRoot
DocumentRoot "/var/www/html/phabricator/webroot"
#######加入index.php
DirectoryIndex index.php index.html index.html.var
<VirtualHost *>
RewriteEngine on
RewriteRule ^/rsrc/(.*) - [L,QSA]
RewriteRule ^/favicon.ico - [L,QSA]
RewriteRule ^(.*)$ /index.php?__path__=$1 [B,L,QSA]
</VirtualHost>
#######啟動必要的服務
service httpd restart
chkconfig httpd on
service mysqld restart
chkconfig httpd on#######更新phabricator
cd /var/www/html/phabricator
./bin/storage upgrade
#######在瀏覽器中輸入網址 192.168.*.* 即可。
-
配置Phabricator
注:在配置svn的url獲取時,svn的地址必須是原生的.這樣才可以生成ssl證書
如:https://svn.qq.net:9443/svn/ProductCenter
此處必須是根目錄
-
開啟LDAP權限
需要擴展LDAP PHP,使用命令
apt-get install php5-ldap
或
yum install php-ldap
然后安裝完成后,要重啟httpd就可以用了
service httpd restart
附件:源調整 接入阿里的源
-
備份
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
-
下載新的CentOS-Base.repo 到
cd /etc/yum.repos.d/
CentOS 5
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
CentOS 6
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
CentOS 7
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
-
之后運行
yum makecache生成緩存
聯系方式:505242941@qq.com
