Phabricator 是一個開源的軟件開發管理工具,由 Facebook 開發并廣泛用于代碼審查、任務管理、代碼托管等。它提供了一系列的工具,如 Differential(代碼審查)、Maniphest(任務管理)、Harbormaster(持續集成)等,幫助開發團隊更高效地協作和管理項目。
本文將詳細介紹如何在 Linux 系統上搭建 Phabricator 開發管理平臺,涵蓋從環境準備到最終配置的全過程。
在開始搭建 Phabricator 之前,確保你已經具備以下條件:
在安裝 Phabricator 之前,需要確保系統上安裝了必要的依賴。
首先,更新系統包:
sudo apt-get update
sudo apt-get upgrade
安裝 PHP、Git、MySQL 和其他必要的軟件包:
sudo apt-get install git apache2 mysql-server php php-mysql php-gd php-curl php-apcu php-cli php-json php-mbstring
Phabricator 使用 Composer 來管理 PHP 依賴。安裝 Composer:
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
使用 Git 克隆 Phabricator 的代碼庫:
cd /var/www/html
sudo git clone https://github.com/phacility/phabricator.git
sudo git clone https://github.com/phacility/arcanist.git
sudo git clone https://github.com/phacility/libphutil.git
確保 Phabricator 目錄的權限正確:
sudo chown -R www-data:www-data /var/www/html/phabricator
sudo chown -R www-data:www-data /var/www/html/arcanist
sudo chown -R www-data:www-data /var/www/html/libphutil
登錄 MySQL 并創建一個新的數據庫和用戶:
mysql -u root -p
在 MySQL 命令行中執行以下命令:
CREATE DATABASE phabricator;
CREATE USER 'phabricator'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON phabricator.* TO 'phabricator'@'localhost';
FLUSH PRIVILEGES;
EXIT;
編輯 Phabricator 的配置文件 phabricator/conf/local/local.json
,添加數據庫連接信息:
{
"mysql.host": "localhost",
"mysql.user": "phabricator",
"mysql.pass": "your_password",
"mysql.port": 3306,
"mysql.database": "phabricator"
}
創建一個新的 Apache 虛擬主機配置文件:
sudo nano /etc/apache2/sites-available/phabricator.conf
添加以下內容:
<VirtualHost *:80>
ServerName phabricator.yourdomain.com
DocumentRoot /var/www/html/phabricator/webroot
<Directory /var/www/html/phabricator/webroot>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/phabricator_error.log
CustomLog ${APACHE_LOG_DIR}/phabricator_access.log combined
</VirtualHost>
啟用站點并重啟 Apache:
sudo a2ensite phabricator.conf
sudo systemctl reload apache2
如果你使用 Nginx,可以創建一個新的配置文件:
sudo nano /etc/nginx/sites-available/phabricator
添加以下內容:
server {
listen 80;
server_name phabricator.yourdomain.com;
root /var/www/html/phabricator/webroot;
index index.php;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
啟用站點并重啟 Nginx:
sudo ln -s /etc/nginx/sites-available/phabricator /etc/nginx/sites-enabled/
sudo systemctl reload nginx
Phabricator 需要發送郵件通知,因此需要配置郵件服務。你可以使用本地郵件服務(如 Postfix)或外部郵件服務(如 Gmail)。
安裝 Postfix:
sudo apt-get install postfix
在安裝過程中,選擇 “Internet Site” 并輸入你的域名。
編輯 Phabricator 的配置文件 phabricator/conf/local/local.json
,添加郵件配置:
{
"phpmailer.smtp-host": "smtp.gmail.com",
"phpmailer.smtp-port": 587,
"phpmailer.smtp-user": "your_email@gmail.com",
"phpmailer.smtp-password": "your_password",
"phpmailer.smtp-protocol": "tls"
}
運行以下命令來初始化 Phabricator:
cd /var/www/html/phabricator
sudo ./bin/config set phabricator.base-uri 'http://phabricator.yourdomain.com/'
sudo ./bin/storage upgrade --force
訪問 http://phabricator.yourdomain.com/
,按照提示創建一個管理員賬戶。
登錄 Phabricator 后,進入 “Config” 頁面,根據需要配置其他設置,如身份驗證、存儲、通知等。
local.json
中的數據庫配置正確。local.json
中的郵件配置正確。通過本文的步驟,你應該已經成功搭建了一個 Phabricator 開發管理平臺。Phabricator 提供了豐富的功能,幫助開發團隊更高效地協作和管理項目。你可以根據需要進一步配置和定制 Phabricator,以滿足團隊的特定需求。
希望本文對你有所幫助,祝你在使用 Phabricator 的過程中取得成功!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。