phabricator 安装使用

Installation Requirements

  • 1 台 Linux host
  • mysql >= 5.5
  • php >= 5.2
  • webserver 服务,apache
  • domain name
    Installing Required Components

RedHat Derivatives Install Script

#!/bin/bash
confirm() {
echo "Press RETURN to continue, or ^C to cancel.";
read -e ignored 
}
RHEL_VER_FILE="/etc/redhat-release"
if [[ ! -f $RHEL_VER_FILE ]]
then
echo "It looks like you're not running a Red Hat-derived distribution."
echo "This script is intended to install Phabricator on RHEL-derived"
echo "distributions such as RHEL, Fedora, CentOS, and Scientific Linux."
echo "Proceed with caution."
confirm 
fi
echo "PHABRICATOR RED HAT DERIVATIVE INSTALLATION SCRIPT";
echo "This script will install Phabricator and all of its core dependencies.";
echo "Run it from the directory you want to install into.";
echo
RHEL_REGEX="release ([0-9]+)\."
if [[ $(cat $RHEL_VER_FILE) =~ $RHEL_REGEX ]]
then
RHEL_MAJOR_VER=${BASH_REMATCH[1]}
else
echo "Ut oh, we were unable to determine your distribution's major"
echo "version number. Please make sure you're running 6.0+ before"
echo "proceeding."
confirm 
fi
if [[ $RHEL_MAJOR_VER < 6 && $RHEL_MAJOR_VER > 0 ]]
then
echo "** WARNING **"
echo "A major version less than 6 was detected. Because of this,"
echo "several needed dependencies are not available via default repos."
echo "Specifically, RHEL 5 does not have a PEAR package for php53-*."
echo "We will attempt to install it manually, for APC. Please be careful."
confirm 
fi
echo "Phabricator will be installed to: $(pwd).";
confirm 
echo "Testing sudo/root..."
if [[ $EUID -ne 0 ]] # Check if we're root. If we are, continue.
then
sudo true
SUDO="sudo"
if [[ $? -ne 0 ]]
then
echo "ERROR: You must be able to sudo to run this script, or run it as root.";
exit 1
fi
fi
if [[ $RHEL_MAJOR_VER == 5 ]]
then
# RHEL 5's "php" package is actually 5.1. The "php53" package won't let us install php-pecl-apc.
# (it tries to pull in php 5.1 stuff) ...
yum repolist | grep -i epel 
if [ $? -ne 0 ]; then
echo "It doesn't look like you have the EPEL repo enabled. We are to add it"
echo "for you, so that we can install git."
$SUDO rpm -Uvh https://download.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm 
fi
YUMCOMMAND="$SUDO yum install httpd git php53 php53-cli php53-mysql php53-process php53-devel php53-gd gcc wget make pcre-devel mysql-server"
else
# RHEL 6+ defaults with php 5.3
YUMCOMMAND="$SUDO yum install httpd git php php-cli php-mysql php-process php-devel php-gd php-pecl-apc php-pecl-json php-mbstring mysql-server"
fi
echo "Dropping to yum to install dependencies..."
echo "Running: ${YUMCOMMAND}"
echo "Yum will prompt you with [Y/n] to continue installing."
$YUMCOMMAND
if [[ $? -ne 0 ]]
then
echo "The yum command failed. Please fix the errors and re-run this script."
exit 1
fi
if [[ $RHEL_MAJOR_VER == 5 ]]
then
# Now that we've ensured all the devel packages required for pecl/apc are there, let's
# set up PEAR, and install apc.
echo "Attempting to install PEAR"
wget https://pear.php.net/go-pear.phar 
$SUDO php go-pear.phar && $SUDO pecl install apc 
fi
if [[ $? -ne 0 ]]
then
echo "The apc install failed. Continuing without APC, performance may be impacted."
fi
pidof httpd 2>&1 > /dev/null 
if [[ $? -eq 0 ]]
then
echo "If php was installed above, please run: /etc/init.d/httpd graceful"
else
echo "Please remember to start the httpd with: /etc/init.d/httpd start"
fi
pidof mysqld 2>&1 > /dev/null 
if [[ $? -ne 0 ]]
then
echo "Please remember to start the mysql server: /etc/init.d/mysqld start"
fi
confirm 
if [[ ! -e libphutil ]]
then
git clone https://github.com/phacility/libphutil.git 
else
(cd libphutil && git pull --rebase)
fi
if [[ ! -e arcanist ]]
then
git clone https://github.com/phacility/arcanist.git 
else
(cd arcanist && git pull --rebase)
fi
if [[ ! -e phabricator ]]
then
git clone https://github.com/phacility/phabricator.git 
else
(cd phabricator && git pull --rebase)
fi
echo
echo
echo "Install probably worked mostly correctly. Continue with the 'Configuration Guide':";
echo
echo " https://secure.phabricator.com/book/phabricator/article/configuration_guide/";

clone 必须代码仓库

$ 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

Configuration

Webserver: Configuring nginx
# /etc/nginx/nginx.conf
#user  nobody;
worker_processes  1;
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
#pid        logs/nginx.pid;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    log_format  main  '$remote_addr - $remote_user [$time_local] $http_host:$server_port $scheme "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for" '
                      '$connection $upstream_addr '
                      '$upstream_response_time $request_time $request_length';
    #access_log  logs/access.log  main;
    sendfile        on;
    #tcp_nopush     on;
    #keepalive_timeout  0;
    keepalive_timeout  65;
    #gzip  on;
    include conf.d/*.conf;
}
/etc/nginx/conf.d/phab.conf
server {
  listen 80;
  server_name phabricator-qa.graviti.cn;
  root        /usr/local/phacility/phabricator/webroot;
  access_log  /var/log/phabricator/access.log main;
  error_log  /var/log/phabricator/error.log;
  client_max_body_size 64m;
  location / {
    index index.php;
    rewrite ^/(.*)$ /index.php?__path__=/$1 last;
  }
  location /index.php {
    try_files $uri =404;
    fastcgi_pass  unix:/tmp/php-cgi.sock;
    fastcgi_index   index.php;
    fastcgi_param  SCRIPT_FILENAME  /usr/local/phacility/phabricator/webroot$fastcgi_script_name;
    include fastcgi_params;
  }
}

配置环境

添加 phd 用户
useradd phd
添加软链
ln -s /usr/local/phacility/phabricator/resources/sshd/phabricator-ssh-hook.sh phabricator-ssh-hook.sh
配置 phab

直接配置 conf/local/local.json 文件

{
  "security.require-https": true,
  "diffusion.ssh-port": 2224,
  "diffusion.ssh-user": "git",
  "phd.user": "phd",
  "cluster.mailers": [
    {
      "key": "local-mailer",
      "type": "sendmail",
      "options": {
        "message-id": true
      }
    }
  ],
  "repository.default-local-path": "/data/repo/",
  "storage.local-disk.path": "/data/phabricator/",
  "phabricator.base-uri": "https://phabricator.xxxx.com",
  "mysql.pass": "Wxxxxxx3",
  "mysql.user": "root",
  "mysql.host": "127.0.0.1"
}

或者,通过命令更改配置

./bin/config set mysql.host 127.0.0.1
./bin/config set mysql.pass xxxxxx
./bin/config set mysql.port 3306
./bin/config set mysql.user root

更新数据库

root@service-3054-190911205326 phabricator]# ./bin/storage upgrade
Before running storage upgrades, you should take down the Phabricator web
interface and stop any running Phabricator daemons (you can disable this
warning with --force).
    Are you ready to continue? [y/N] y
Loading quickstart template onto "127.0.0.1"...
Applying patch "phabricator:db.paste" to host "127.0.0.1"...
Applying patch "phabricator:20190523.myisam.01.documentfield.sql" to host "127.0.0.1"...
Applying patch "phabricator:20190718.paste.01.edge.sql" to host "127.0.0.1"...
Applying patch "phabricator:20190718.paste.02.edgedata.sql" to host "127.0.0.1"...
Applying patch "phabricator:20190718.paste.03.paste.sql" to host "127.0.0.1"...
Applying patch "phabricator:20190718.paste.04.xaction.sql" to host "127.0.0.1"...
Applying patch "phabricator:20190718.paste.05.comment.sql" to host "127.0.0.1"...
Applying patch "phabricator:20190802.email.01.storage.sql" to host "127.0.0.1"...
Applying patch "phabricator:20190802.email.02.xaction.sql" to host "127.0.0.1"...
Applying patch "phabricator:20190815.account.01.carts.php" to host "127.0.0.1"...
Applying patch "phabricator:20190815.account.02.subscriptions.php" to host "127.0.0.1"...
Applying patch "phabricator:20190816.payment.01.xaction.sql" to host "127.0.0.1"...
Applying patch "phabricator:20190816.subscription.01.xaction.sql" to host "127.0.0.1"...
Applying patch "phabricator:20190822.merchant.01.view.sql" to host "127.0.0.1"...
Applying patch "phabricator:20190909.herald.01.rebuild.php" to host "127.0.0.1"...
Storage is up to date. Use "storage status" for details.
Synchronizing static tables...
Verifying database schemata on "127.0.0.1"...

Database                Table                Name        Issues
phabricator_conpherence  conpherence_index                  Better Table Engine Available
phabricator_differential differential_revision phid         Surplus Key
phabricator_differential differential_revision key_modified Missing Key
phabricator_differential differential_revision key_phid     Missing Key
phabricator_phortune     phortune_accountemail key_account  Missing Key
phabricator_phortune     phortune_accountemail key_address  Missing Key
phabricator_phortune     phortune_accountemail key_phid     Missing Key
Applying schema adjustments...
Done.                                                                         
Completed applying all schema adjustments.
 ANALYZE  Analyzing tables...                                                 
Done.                                                                         
 ANALYZED  Analyzed 535 table(s).
使用 phd 管理后台

phd 是一个命令行程序(位于 phabricator/bin/phd )

[root@service-3054-190911205326 phabricator]# ./bin/phd help
NAME
      phd - manage daemons
SYNOPSIS
      phd command [options]
          Manage Phabricator daemons.
WORKFLOWS
。。。。。
Use help command for a detailed command reference.
Use --show-standard-options to show additional options.

通常情况下,你会使用:

  • phd start 启动所有后台进程;
  • phd restart 重启所有后台进程;
  • phd status 列出所有后台进程;
  • phd stop 停止所有后台进程。

如果你想要更细粒度的控制,你可以使用:

  • phd launch 启动单个后台进程;
  • phd debug 调试

启动 phabricator

[root@service-3054-190911205326 phabricator]# ./bin/phd start
Freeing active task leases...
Freed 0 task lease(s).
Starting daemons as phd
Launching daemons:
(Logs will appear in "/var/tmp/phd/log/daemons.log".)
    (Pool: 1) PhabricatorRepositoryPullLocalDaemon
    (Pool: 1) PhabricatorTriggerDaemon
    (Pool: 1) PhabricatorFactDaemon
    (Pool: 4) PhabricatorTaskmasterDaemon
Done.
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 204,732评论 6 478
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 87,496评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 151,264评论 0 338
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,807评论 1 277
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,806评论 5 368
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,675评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,029评论 3 399
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,683评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 41,704评论 1 299
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,666评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,773评论 1 332
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,413评论 4 321
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,016评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,978评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,204评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 45,083评论 2 350
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,503评论 2 343

推荐阅读更多精彩内容