1. 程式人生 > >在ubuntu上搭建Phabricator 伺服器

在ubuntu上搭建Phabricator 伺服器

一 安裝要求

Phabricator 是一個LAMP應用套件, 因此最基本的要求就是LAMP環境:

  • Linux:Linux的不同發行版及變種是必需的。Mac OS X是一個可接受的Linux變種,Windows不是。Phabricator不能安裝在Windows系統上。在Mac OS X,Amazon Linux,Ubuntu,RHEL和CentOS上執行的 Phabricator 有活躍的貢獻者。
  • Apache(或nginx,或lighttpd):需要Apache 2.2.7以上版本。
  • MySQL:MySQL必需
  • PHP:需要PHP5.2以上版本
  1. LAMP: Linux+Apache+Mysql/MariaDB+Perl/PHP/Python一組常用來搭建動態網站或者伺服器的開源軟體,本身都是各自獨立的程式,但是因為常被放在一起使用,擁有了越來越高的相容度,共同組成了一個強大的Web應用程式平臺。

二 安裝必須的元件

Phabricator安裝必須的元件包括

  • git (usually called “git” in package management systems)
  • Apache (usually “httpd” or “apache2”) (or nginx)
  • MySQL Server (usually “mysqld” or “mysql-server”)
  • PHP (usually “php”)
  • 必須的 PHP 擴充套件: mbstring, iconv, mysql (or mysqli), curl, pcntl (these might be something like “php-mysql” or “php5-mysql”)
  • 可選的PHP 擴充套件: gd, apc (安裝該擴充套件如果有困惑,請看下面的APC安裝說明), xhprof (僅在你對Phabricator做二次開發時需要) 以上大部分元件在Ubuntu上可以通過指令碼install_ubuntu.sh完成。 ubuntu下獲取檔案的命令:
    wget http://www.phabricator.com/rsrc/install/install_ubuntu.sh 
    
安裝APC (可選)

如同所有寫在PHP中的東西一樣, Phabricator 在APC安裝完畢後,執行會更快。你首先需要先安裝“pcre-devel”:

sudo apt-get install pcre-devel

然後你有兩個選擇。一個是安裝via PECL(需要首先測試一下)

sudo pecl install apc

安裝 APC 是可選的,但是這裡 強烈推薦安裝 一旦 APC 安裝完成,測試就可以執行了:

php -i | grep apc

如果該命令無法執行,那就新增

extension=apc.so

到 “/etc/php.d/apc.ini” 或 “php.ini” 檔案中。 可以通過

php -i

找到該檔案。

三 獲取phabricator及其依賴包

$ 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

四 配置phabricator

1. WEB伺服器:配置Apache

  • 設定一個域名指向你的主機
    	Sudo Vim /etc/hosts
    add:
    	127.0.0.1 phabricator.my.com
    
  • 建立一個VirtualHost條目(放置Phabricator到一個二級域名上) 進入站點配置目錄
    $ cd /etc/apache2/site-available/
    

該目錄用於存放虛擬機器的配置檔案。 建立一個虛擬機器的配置檔案

$sudo vim phabricator.conf

新增如下內容:

<VirtualHost *:80>
  # Change this to the domain which points to your host.
  ServerName phabricator.my.com

  # 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 /path/to/phabricator/webroot

  RewriteEngine on
  RewriteRule ^(.*)$          /index.php?__path__=$1  [B,L,QSA]
  RewriteRule ^/rsrc/(.*)     -                       [L,QSA]
  RewriteRule ^/favicon.ico   -                       [L,QSA]

 # If Apache isn't currently configured to serve documents out of the
 # directory where you put Phabricator, you may also need to add
 # <Directory /> section. 
  <Directory /path/to/phabricator/webroot>
	           Options Indexes FollowSymLinks Includes ExecCGI
	           AllowOverride None
	           Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
  1. <Directory部分也可以新增到/etc/apache2/apache2.conf中。
  2. 這裡用的是預設埠80,要想通過其他埠(8080)訪問,首先我們得讓apache2監聽埠該埠: 修 改/etc/apache2/ports.conf,增加: Listen 8080 儲存編輯的配置檔案後, 需要啟用該配置。 $ sudo a2ensite phabricator.conf 完成後他會提示你需要重新載入一些東西, 這裡按照提示執行一下。 $ sudo service apache2 reload
  • 重啟Apache服務

    sudo /etc/init.d/apache2 restart
    

    重啟時遇到如下問題時: 需要在/etc/apache2/apache2.conf配置文件中加入下面的一句: ServerName 127.0.0.1:80

2.儲存:配置MySQL

設定中,你需要配置MySQL。執行MySQL,驗證是否能正常連線。如果有問題,請參考MySQL的幫助文件。如果MySQL正常工作,你需要載入Phabricator的模式,執行命令:

phabricator/ $ ./bin/storage upgrade

根據提示進行操作即可,將Phabricator的配置檔案載入到mysql中。 如果你配置了一個無特權的使用者以連線資料庫,你將不得不重新設定為root使用者或其他的管理員以使模式能被應用。

phabricator/ $ ./bin/storage upgrade --user <user> --password <password>

可以使用 – force 引數來避免指令碼進行提示,對mysql強行載入配置檔案。

phabricator/ $ ./bin/storage upgrade --force

注意:每當Phabricator進行了更新,都需要執行storage upgrade。 每當server關閉後再次開啟,需要重新啟動phabricator。頁面資訊會提示你該怎麼做。

3. 驗收Phabricator

  • 在瀏覽器中輸入域名,It Works!

It Works!

  • 客戶端登陸 在客戶端hosts檔案中新增
    192.168.31.90(server IP)  phabricator.my.com
    

下一步

繼續: