Mac OS下基于XAMPP搭建Phabricator
Phabricator作為Facebook官方開發(fā)并使用的可視化代碼評審工具看政,功能很強大凯楔,而且屬于開源項目哪审。我們小組最近準備在開發(fā)流程中加強CodeReview饶深,打算采用這款工具餐曹。
閱讀本文之前,可先簡單的過一遍 Phabricator官方安裝指引文檔
[TOC]
1. 運行環(huán)境依賴
Phabricator是一款LAMP (Linux, Apache, MySQL, PHP) 應用敌厘,由于我們是基于MacOS搭建台猴,所以此處我們還需要提前安裝的東西如下:
為了省時省事,我采用集成安裝包XAMPP來安裝上述工具和環(huán)境俱两。
可直接點擊這里XAMPP下載地址找到對應的dmg安裝即可饱狂,本文下載的是XAMPP for OS X 5.6.21
安裝完成后,打開xampp-manager宪彩,就可以看到以下GUI界面休讳,在這個界面可以進行一些可視化的操作:
2. 下載安裝必要的運行組件
按照官方提示的步驟:
$ cd somewhere/ # pick some install directory
somewhere/$ git clone https://github.com/phacility/libphutil.git
somewhere/$ git clone https://github.com/phacility/arcanist.git
somewhere/$ git clone https://github.com/phacility/phabricator.git
但實際上我在安裝的過程發(fā)現(xiàn)下載這幾個組件的速度實在是慢得可憐,這里我提供一個CSDN下載地址供大家打包下載尿孔,應該會快很多俊柔。下載后解壓到對應目錄即可筹麸。
3. 設置虛擬主機映射
由于我們是使用XAMPP搭建的Apache+PHP環(huán)境,所以設置映射大概步驟如下:
3.1 開啟虛擬主機功能
用文本編輯器或者vim打開 /Applications/XAMPP/xamppfiles/etc/httpd.conf 這個文件雏婶,找到如下兩行內(nèi)容:
# Virtual hosts
#Include /Applications/XAMPP/etc/extra/httpd-vhosts.conf
去掉第二行前面的#號注釋并保存物赶,這樣才能使Apache去加載我們自定義的虛擬主機配置文件:
# Virtual hosts
Include /Applications/XAMPP/etc/extra/httpd-vhosts.conf
3.2 創(chuàng)建自己的虛擬主機
用文本編輯器或者vim打開 /Applications/XAMPP/xamppfiles/etc/extra/httpd-vhosts.conf 這個文件∩薪荆可以簡單粗暴注釋掉其他內(nèi)容块差,添加以下內(nèi)容:
<VirtualHost *>
# Change this to the domain which points to your host.
ServerName 192.168.3.13
# Change this to the path where you put 'phabricator' when you checked it
# out from GitHub when following the Installation Guide.
#
# Make sure you include "/webroot" at the end!
DocumentRoot /Users/Kido/Documents/app/phabricator/webroot
<Directory "/Users/Kido/Documents/app/phabricator/webroot">
Options Indexes FollowSymLinks Includes execCGI
AllowOverride All
Require all granted
</Directory>
RewriteEngine on
RewriteRule ^/rsrc/(.*) - [L,QSA]
RewriteRule ^/favicon.ico - [L,QSA]
RewriteRule ^(.*)$ /index.php?__path__=$1 [B,L,QSA]
</VirtualHost>
注:
此處ServerName添加的是自己機器的IP地址(有域名可以填寫域名)。
DocumentRoot對應下載的phabricator的webroot目錄倔丈,Directory亦是如此憨闰。
設置完成后保存,重啟Apache需五。
3.3 訪問驗證
確保上述設置的路徑正確無誤后鹉动,打開瀏覽器訪問上述自己的IP地址,看看是否能成功訪問宏邮。
若出現(xiàn)403錯誤泽示,請打開 /Applications/XAMPP/xamppfiles/etc/httpd.conf 文件,并找到以下內(nèi)容行:
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User daemon
Group daemon
將User后面對應的名字更改為自己機器的登陸用戶名蜜氨。
User yourusername
更改保存后重啟Apache械筛,此時應該可以順利的看到Phabricator的界面,一開始可能會提示你“storage upgrade”之類的飒炎,別緊張埋哟,還沒全部配置完,下面會講到郎汪。
4. 配置mysql數(shù)據(jù)庫
進入phabricator目錄運行命令:
phabricator/ $ ./bin/storage upgrade
第一次可能失敗赤赊,會提示你設置mysql的地址、用戶名煞赢、密碼等抛计,根據(jù)輸出的提示一步步設置即可。mysql默認用戶名是root照筑,密碼為空吹截,以我為例,設置命令如下:
# 由于mysql安裝在本機凝危,這里的mysql.host可填localhost或127.0.0.1或本機實際IP
phabricator/ $ ./bin/config set mysql.host localhost
phabricator/ $ ./bin/config set mysql.user root
phabricator/ $ ./bin/config set mysql.pass ""
設置完成后饭弓,重新運行:
phabricator/ $ ./bin/storage upgrade
等待運行完成,重新嘗試在瀏覽器打開訪問自己的host媒抠,看是否能正常訪問。
若出現(xiàn)以下錯誤提示:
Site Not Found
This request asked for "/" on host "192.168.3.13", but no site is configured which can serve this request.
不怕咏花,很簡單趴生,只需要設置一下phabricator的base uri即可阀趴。執(zhí)行以下命令:
phabricator/ $ ./bin/config set phabricator.base-uri 'http://192.168.3.13'
再次訪問,順利的話苍匆,第一次會看到創(chuàng)建帳號的頁面刘急,在頁面上按提示自行創(chuàng)建即可。
若想在命令行創(chuàng)建用戶浸踩,可以執(zhí)行如下語句叔汁,然后按提示一步步填寫完成即可:
phabricator/ $ ./bin/accountadmin
對應刪除用戶的命令如下:
phabricator/ $ ./bin/remove destroy @username
登陸后的頁面大致如下:
5. 相關配置
5.1 啟動后臺進程
phabricator使用了一些后臺程序(daemons)去處理一系列相關的任務,比如記錄操作日志检碗、發(fā)送郵件等据块。為確保這些daemons處于運行狀態(tài),可以執(zhí)行:
phabricator/ $ ./bin/phd start
若啟動失敗折剃。提示一些問題另假,請根據(jù)問題描述Google搜索一下即可。
5.2 郵件配置
郵件發(fā)送我采用SMTP方式怕犁,使用自己的163郵箱進行發(fā)送边篮。主要設置如下:
- Config->Config->Mail
- Config->Config->PHPMailer
(此處在網(wǎng)頁端無法直接設置,請根據(jù)網(wǎng)頁端的提示到命令行執(zhí)行)
以163郵箱為例奏甫,大概設置命令如下:
phabricator/ $ ./bin/config set phpmailer.mailer smtp
phabricator/ $ ./bin/config set phpmailer.smtp-host smtp.163.com
phabricator/ $ ./bin/config set phpmailer.smtp-port 25
phabricator/ $ ./bin/config set phpmailer.smtp-user user@163.com
phabricator/ $ ./bin/config set phpmailer.smtp-password **
若為exmail之類的走ssl協(xié)議的节芥,則還需要設置smtp-protocol:
phabricator/ $ ./bin/config set phpmailer.smtp-protocol ssl
5.3 未完待續(xù)...
6. 參考資料
《 Configuring VirtualHosts in XAMPP on Mac 》
《 Phabricator Installation Guide 》