想把Phabricator搭建在MAMP上,但是網(wǎng)上搜不到太多相關(guān)資料,因此自己借鑒LAMP及外國(guó)友人的做法,進(jìn)行一下簡(jiǎn)單的移植。這里做個(gè)記錄。
主要借鑒資料:
搭建安裝Phabricator代碼評(píng)審工具
CONFIGURING PHABRICATOR WITH MAMP
環(huán)境(2017.2.20):
macOS Sierra 10.12.3
MAMP Pro MAMP PRO 4.1.1(Apache 2.2.31 , PHP 7.1.1)
Phabricator最新版(要求 PHP 7.1+)
[TOC]
MAMP和Phabricator下載安裝
MAMP
這個(gè)就不多說(shuō)了,除了Phabricator站點(diǎn),自己沒(méi)事裝個(gè)wiki還是其他網(wǎng)站還是很方便的。去官網(wǎng)下載安裝即可。作為開發(fā)者,這種好東西還是可以去支持一把正版的。
我一般使用的端口號(hào)如下:

另外,MAMP中MySQL的密碼,為了安全,需要你自己去修改,這個(gè)資料多多,也很簡(jiǎn)單,這里就不贅述了。
Phabricator
選擇一個(gè)你喜歡的目錄存放Phabricator,我是扔到iCloud Drive中去了,進(jìn)入文件夾,使用git clone下載Phabricator及相關(guān)組件。
$ 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
設(shè)置虛擬主機(jī)映射
MAMP新建host
- 設(shè)置IP,如果設(shè)置了內(nèi)網(wǎng)IP,就可以在內(nèi)網(wǎng)中使用了。
- 設(shè)置端口號(hào),比如我這里設(shè)置為1234
- 將啟動(dòng)文件夾設(shè)置到
habricator/webroot文件夾 - 在Extension中設(shè)置參數(shù)
效果圖如下:

設(shè)置Apache
- Options for <Directory> directive 使用默認(rèn)勾選
- 在Additional for <VirtualHost>directive: 中加入以下代碼:
RewriteEngine on
RewriteRule ^/rsrc/(.*) - [L,QSA]
RewriteRule ^/favicon.ico - [L,QSA]
RewriteRule ^(.*)$ /index.php?__path__=$1 [B,L,QSA]
示意圖如下:

這些數(shù)據(jù)是從LAMP那篇文章拿過(guò)來(lái)的,后來(lái)發(fā)現(xiàn)官方文檔上就有。

以后這個(gè)設(shè)置不靈光了,照著官網(wǎng)的寫就可以了。
設(shè)置MySQL
啟動(dòng)服務(wù)器,現(xiàn)在你打開本站點(diǎn),會(huì)發(fā)現(xiàn)是這樣的圖。

按照它的提示,升級(jí)這4個(gè)值:
-
host:數(shù)據(jù)庫(kù)的ip地址,這里在本機(jī)上,繼續(xù)使用localhost即可。 -
port:數(shù)據(jù)庫(kù)的端口地址,我用的3306,可以去Ports面板中查看。 -
user:數(shù)據(jù)庫(kù)的user,還是本機(jī),root即可 -
pass:user對(duì)應(yīng)的密碼,前面說(shuō)了,自行修改
執(zhí)行這4個(gè)命令,設(shè)置好之后,再刷新界面,如果提示你輸入
./bin/storage upgrade
那么恭喜你,數(shù)據(jù)庫(kù)對(duì)上了,關(guān)閉Apache,保持MySQL的打開,輸入上述命令連接數(shù)據(jù)庫(kù)吧。
設(shè)置Phabricator
到了這里,打開Phabricator網(wǎng)站(如host:port方式),你就能夠進(jìn)入Phabricator了,然后你會(huì)發(fā)現(xiàn)有一些Unresolved Setup Issues等待你去解決。
啟動(dòng)daemons
每次重啟電腦后,也要記得把這個(gè)打開,這東西就是用來(lái)刷新數(shù)據(jù)的。
1.安裝pcntl插件
首先你需要安裝pcntl插件。因?yàn)镸AMP用的自己的PHP,而macOS也自己內(nèi)置了PHP,所以我也不知道pcntl到底是需要安裝到哪里。因此,經(jīng)過(guò)一輪又一輪的折騰,我把系統(tǒng)本身的PHP從5.6升級(jí)到了7.1.1,然后把pcntl插件各復(fù)制了一份,就好了??。
#homebrew下載pcntl插件
brew install homebrew/php/php71-pcntl
復(fù)制到MAMP中的PHP插件中

同理復(fù)制到系統(tǒng)的PHP的對(duì)應(yīng)位置中。
然后修改phpX.X.X/conf/php.ini,也是2處,調(diào)用pcntl.so。

重啟MAMP服務(wù),看看是不是好了呢?這一步我也做的糊里糊涂的,歡迎小伙伴們進(jìn)行反饋,一些工作肯定是多余了。
啟動(dòng)Phabricator中的daemons
進(jìn)入Phabricator文件夾,使用以下命令對(duì)daemons進(jìn)行控制。
啟動(dòng):bin/phd start
停止:bin/phd stop
重啟:bin/phd restarat
查看:bin/phd status
Base URI設(shè)置
網(wǎng)頁(yè)提示已經(jīng)夠詳細(xì)了,照著輸入就可以了。
Base URI Not Configured
The base URI for this install is not configured, and major features will not work properly until you configure it.
You should set the base URI to the URI you will use to access Phabricator, like "http://phabricator.example.com/".
Include the protocol (http or https), domain name, and port number if you are using a port other than 80 (http) or 443 (https).
Based on this request, it appears that the correct setting is:
http://192.168.39.195:1234/
To configure the base URI, run the command shown below.
Run this command:
phabricator/ $ ./bin/config set phabricator.base-uri 'http://192.168.39.195:1234/'
## 提示設(shè)置storage.local-disk.path
如果有這個(gè)的提示,設(shè)置這個(gè)的命令如下:
phabricator/ $ ./bin/config set storage.local-disk.path
我也不知道有什么用,以及需不需要設(shè)置。
## 提示設(shè)置repository.default-local-path
同上,不知道什么用,以及需不需要設(shè)置,命令如下:
phabricator/ $ ./bin/config set repository.default-local-path
## PHP擴(kuò)展提示啟用
比如apcu,opchache擴(kuò)展,PHP7.1.1自帶,如果啟用,那么MAMP其他的PHP站點(diǎn)也會(huì)啟用,為了全局,愚見不建議啟用。
如果要啟用,`File > Edit Template > PHP (php.ini) ` 中打開相應(yīng)注釋。
## MySQL參數(shù)修改
比如` innodb_buffer_pool_size`字段,這里推薦設(shè)置成1G以上,個(gè)人服務(wù)器,沒(méi)必要提升。
如果要修改,`File > Edit Template > MySQL ` 中修改相應(yīng)字段。
## 其他
其他剩余issue我也就先扔那里了,反正phabricator能正常運(yùn)行,暫時(shí)夠用就行,以后再來(lái)更新,我還沒(méi)開始玩phabricator呢。
# 尾聲
剩余的設(shè)置Phabricator的賬號(hào)密碼啥的,這個(gè)簡(jiǎn)單,大家自己搞定,至少需要設(shè)置一個(gè)Provider。
放個(gè)圖慶祝一下:

經(jīng)過(guò)這一輪2天的折騰,就算沒(méi)有別的,對(duì)MAMP的使用和對(duì)PHP的理解倒是增強(qiáng)了不少,也算是意料之外的獲得了。