關于Phabricator部署時候的疑難點

Phabricator的搭建

首先是關于Phabricator的搭建問題,由于我們這里對于Phabricator的目的只是CodeReview,于是我把Phabricator部署在了我們的打包機器上,我用的是Mac OSX。

關于Phabricator的基本安裝使用方法可以查詢這份基礎的官方文檔.

Phabricator是一款LAMP (Linux, Apache, MySQL, PHP) 應用,我們需要在服務器上部署上述的環境;推薦大家去看下面這篇文章,這是一篇詳細安裝Phabricator的教程,推薦使用XAMPP來安裝上述的運行環境,這樣對于小白來說會比較方便,XAMPP基本上提供了主流的操作系統版本,Windows、Linux、Solaris、Mac OS X都是支持;
基本按照上面的教程可以很順利的安裝上Phabricator;

還有就是安裝的時候可能會出現端口號沖突的問題,因為我的服務器上原來裝了Jekins,現在裝了Phabricator,我把8080端口給了Jekins,80端口給了Phabricator。

Phabricator本身提供了付費服務,可以直接使用,缺點就是每年都要付費而且需要翻墻出去;所以自己部署是一個很好的選擇;

基本上按照上面的教程可以順利的完成安裝;

啟動Phabricator

按照上述的教程我們可以順利打開Phabricator,注冊完管理員賬號以后,Phabricator會提示你很多的警告,基本上上面的警告很多都是需要解決的,但是一小部分可以忽略,并不影響我們的使用。

  • No Authentication Providers Configured
    You have not configured any authentication providers yet. You should add a provider (like username/password, LDAP, or GitHub OAuth) so users can register and log in. You can add and configure providers using the Auth Application.

你需要選擇一個或者多個登錄注冊方式,Phabricator支持多種方式的登錄注冊,包括賬號密碼,LDAP,第三方賬號授權登錄等等;由于默認情況下沒有Providers,所以你需要設置一種登錄注冊方式,我這里只選擇了Username/Password方式,你可以根據自己的要求進行配置。

  • 沒有配置phabricator.base-uri沒有配置

需要通過bin/config set phabricator.base-uri <value>進行設置,也就是你當前服務器的地址。

  • Small MySQL "max_allowed_packet"
    On host "localhost", MySQL is configured with a small "max_allowed_packet" (1048576), which may cause some large writes to fail. The recommended minimum value for this setting is "33554432".

my.cnf文件中,修改max_allowed_packet字段,默認為1M,我們需要修改為32M。

  • MySQL May Run Slowly
    Database host "localhost" is configured with a very small innodb_buffer_pool_size (16 MB). This may cause poor database performance and lock exhaustion.
    There are no hard-and-fast rules to setting an appropriate value, but a reasonable starting point for a standard install is something like 40% of the total memory on the machine. For example, if you have 4GB of RAM on the machine you have installed Phabricator on, you might set this value to 1600M.

my.cnf文件中,修改max_allowed_packet字段,默認為16M,我們需要修改1600M;

  • MySQL STRICT_ALL_TABLES Mode Not Set;On database host "127.0.0.1", the global sql_mode is not set to STRICT_ALL_TABLES. It is strongly encouraged that you enable this mode when running Phabricator.

對于事務表,當啟用STRICT_ALL_TABLES或STRICT_TRANS_TABLES模式時,如果語句中有非法或丟失值,則會出現錯誤。語句被放棄并滾動。

my.cnf文件中,添加sql_mode=STRICT_ALL_TABLES字段;

  • PHP Extension "APCu" Not Installed
    Installing the "APCu" PHP extension will improve performance. This extension is strongly recommended. Without it, Phabricator must rely on a very inefficient disk-based cache.

PHP版本也很煩,首先apc不支持PHP5.4級以下的版本,貌似只支持PHP7.0以上,但是Phabricator又不支持PHP7.0,所以搞得很煩,最后下載了一個XAMMP的7.1.2版本;

如果你使用了XAMMP,那么你必須保持PHP版本在7.0以上,然后使用sudo /Applications/XAMPP/xamppfiles/bin/pecl install apc
就可以了,安裝完成以后在php.ini中添加extension=apcu.so就可以了。

  • Phabricator Daemons Are Not Running
    The Phabricator daemons are not running, so Phabricator will not be able to perform background processing (including sending email, rebuilding search indexes, importing commits, cleaning up old data, and running builds).

我們需要啟動后臺的phd服務,否則無法發送郵件,清理舊數據,構建搜索索引等等;

 ./bin/phd start

可能會報ERROR: The PHP extension 'pcntl' is not installed. You must install it to run daemons on this machine.

這個問題相當的麻煩,主要的流程可以Google xammp 安裝pcntl插件;然后遇到的坑事,首先要保證PHP對應的版本與pcntl的版本一致,
其次是在php.ini中添加extension=pcntl.so的時候可能還是會報上面的這個錯,原因就是對應的php.ini的文件不對,可以通過查看php -i的命令,查看Loaded Configuration File是否為nono,它可能找到的并不是XAMMP目錄下的文件,因為環境變量中啟動的php是在/etc這個目錄下,所以要找到對應的正確關系。

  • Missing Repository Local Path
    The directory for local repositories (/var/repo/) does not exist, or is not readable by the webserver. Phabricator uses this directory to store information about repositories. If this directory does not exist, create it:

我們手動創建這個存放代碼倉庫的目錄:mkdir -p '/var/repo/'
同時需要設置對應的config里面的key, ./bin/config set repository.default-local-path /var/repo/

Phabricator使用文檔
  • 安裝瀏覽器通知服務
    安裝通知服務,需要安裝Node.js模塊,去官網安裝下載就可以;接下來需要安裝ws(npm install ws),等兩者都安裝結束以后,我們就需要運行如下命令:
bin/aphlict start

如果你沒有安裝pcntl,如果沒有安裝pcntl的話就會報錯,安裝pcntl的教程可以參考上面。

  • 安裝Email的配置

配置mail:通過web訪問phabricator并在頁面上進行配置:
用administrator賬號登錄后,在administration欄選擇Config進入
1)選擇mail,設置:
metamta.default-address -- fucking@163.com // 注意:這里必須要用與smtp服務器對應的郵箱地址,不然郵件發不出去
metamta.domain -- phabricator.myproject.com //改不改無所謂,我用的是默認的
metamta.mail-adapter: set to "PhabricatorMailImplementationPHPMailerAdapter" //修要修改
metamta.send-immediately: Send Via Daemons //需要修改
2)選擇PHPMailer,設置:
phpmailer.mailer: set to "smtp". //需要修改
phpmailer.smtp-host: smtp.163.com //填寫你的163郵箱的smtp地址!
phpmailer.smtp-port: 25 //修要修改
phpmailer.smtp-user: fucking //你郵箱的用戶名
phpmailer.smtp-password: fuck //你郵箱的密碼
配置完畢后,可以在Administration-MetaMTA下進行發送郵件的測試,注意需要添加一個User組用戶,無法直接向System Agent組用戶發送郵件 (我沒有檢測因為沒找到地方!)

同時需要配置metamta.default-address的地址就是你的郵箱地址;

  • 配置.arcconfig文件

首先需要安裝Arcanist的源碼拷貝到本地,

  1. somewhere git clone git://github.com/facebook/libphutil.git
  2. somewhere git clone git://github.com/facebook/arcanist.git

將arc的路徑加入到系統路徑中

export PATH=$PATH:/somewhere/arcanist/bin/

arc配置

配置arc的默認編輯器,我使用vim

arc set-config editor "vim"

配置默認的phabricator的uri,uri為團隊的phabricator主頁的url

arc set-config default http://phabricator.example.com

在項目的根目錄下建.arcconfig配置文件,文件中至少要填入以下內容

{
  "project_id" : "your project name",
  "conduit_uri" : "your phabricator url"
}

為項目安裝證書,用于phabricator的認證

arc install-certificate

找到your_phabricator_url/conduit/token/ 填入對應的token。

關于lint的配置

我們需要在.arcconfig文件中增加一個配置,load字段,下載OC代碼需要對應的lint資源,https://github.com/vhbit/clang-format-linter;

{
  "project_id" : "your project name",
  "conduit_uri" : "your phabricator url",
  "load" : ["/somewhere/clang-format-linter"]
}

同時需要在添加.arclint以及自定義配置的.clang-format文件;

?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容

  • 目錄0x10 概述0x20 我的應用環境0x30 路線圖0x40 安裝0x41 LNMP環境的安裝0x42 Pha...
    zhangweiheb閱讀 61,094評論 36 62
  • Spring Cloud為開發人員提供了快速構建分布式系統中一些常見模式的工具(例如配置管理,服務發現,斷路器,智...
    卡卡羅2017閱讀 134,886評論 18 139
  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi閱讀 7,430評論 0 10
  • 官網地址 點此前往 功能簡介 支持 MacOS Windows Linux 老爺、用戶等級、勛章等級標識同步B站原...
    荼蓼子閱讀 49,545評論 13 16
  • 2018年2月19日,星期一,晴。 “明天我們也去看海鷗,好嗎?”柳眉看到朋友圈里大家都在曬圖,雪白的海鷗或游泳,...
    春山雨閱讀 472評論 10 15