How to Install and Configure Phabricator on CentOS 7

Updated on May 20, 2016
How to Install and Configure Phabricator on CentOS 7 header image

Phabricator is an advanced open source software development platform which can be used to:

  • Review and audit code.
  • Host Git/Hg/SVN repos.
  • Track bugs.
  • Manage projects.
  • Communicate with team members.
  • And do much more!

Thanks to its abundant features and exceptional performance, Phabricator is getting more and more popular in the open source software community.

In this article, I will show you how to install Phabricator on a Vultr CentOS 7 server instance.

Prerequisites

  • Deploy a Vultr CentOS 7 server instance from scratch;
  • Log in from the SSH terminal using a non-root sudo user.

Step 1: System update

Update your CentOS 7 system, then reboot:

yum update -y && shutdown -r now

After the system boots, log in as a non-root user with sudo access.

Step 2: Install MariaDB

Install the MariaDB server:

sudo yum install mariadb mariadb-server

Start and enable the MariaDB service:

sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service

For security purposes, run the MySQL secure installation utility:

sudo /usr/bin/mysql_secure_installation

Finish this process in accordance with the instructions below:

Enter current password for root (enter for none): Enter
Set root password? [Y/n]: Y
New password:<your-password>
Re-enter new password:<your-password>
Remove anonymous users? [Y/n]: Y
Disallow root login remotely? [Y/n]: Y
Remove test database and access to it? [Y/n]: Y
Reload privilege tables now? [Y/n]: Y

Step 3: Install Apache

Install the Apache web server using YUM:

sudo yum install httpd

Modify the default configuration in order to enhance security:

sudo sed -i 's/^/#&/g' /etc/httpd/conf.d/welcome.conf
sudo sed -i "s/Options Indexes FollowSymLinks/Options FollowSymLinks/" /etc/httpd/conf/httpd.conf

Start and enable the Apache service:

sudo systemctl start httpd.service
sudo systemctl enable httpd.service

Step 4: Install PHP

Install PHP and necessary extensions:

sudo yum install php php-mysqli php-mbstring php-gd php-curl php-cli php-common php-process

Step 5: Install git

sudo yum install git

Step 6: Download and install Phabricator

cd ~
mkdir phabricator
cd phabricator
git clone https://github.com/phacility/libphutil.git
git clone https://github.com/phacility/arcanist.git
git clone https://github.com/phacility/phabricator.git
cd ~
sudo chown -R apache: ~/phabricator
sudo mv ~/phabricator /var/www/html

Step 7: Setup a virtual host for Phabricator

sudo vi /etc/httpd/conf.d/phabricator.conf

Populate the following code segment:

Note: You need to replace admin@example.com, phabricator.example.com, www.phabricator.example.com, /var/log/httpd/phabricator.example.com-error_log, and /var/log/httpd/phabricator.example.com-access_log with your own values.

<VirtualHost *:80>
	ServerAdmin admin@example.com
	DocumentRoot /var/www/html/phabricator/phabricator/webroot/
	ServerName phabricator.example.com
	ServerAlias www.phabricator.example.com
	RewriteEngine on
	RewriteRule ^/rsrc/(.*)     -                       [L,QSA]
	RewriteRule ^/favicon.ico   -                       [L,QSA]
	RewriteRule ^(.*)$          /index.php?__path__=$1  [B,L,QSA]
	<Directory /var/www/html/phabricator/phabricator/webroot/>
		AllowOverride All
	</Directory>
	ErrorLog /var/log/httpd/phabricator.example.com-error_log
	CustomLog /var/log/httpd/phabricator.example.com-access_log common
</VirtualHost>

Save and quit:

:wq

Restart the Apache service in order to put your modifications into effect:

sudo systemctl restart httpd.service

Step 8: Setup the MariaDB credentials for Phabricator

Before you can use Phabricator, you need to setup the MariaDB credentials:

cd /var/www/html/phabricator/phabricator/
sudo ./bin/config set mysql.host localhost
sudo ./bin/config set mysql.port 3306
sudo ./bin/config set mysql.user root
sudo ./bin/config set mysql.pass <your-MySQL-root-password>

Populate Phabricator schemes:

./bin/storage upgrade

During this process, you need to input "y" twice:

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

...

MySQL needs to copy table data to make some adjustments, so these migrations may take some time.

    Fix these schema issues? [y/N] y

Step 9: Modify firewall rules and setup a Phabricator admin account

You need to allow inbound traffic on default HTTP port 80:

sudo firewall-cmd --zone=public --permanent --add-service=http
sudo firewall-cmd --reload

Then use your web browser to visit:

http://<your-Vultr-server-IP>

You will be presented with the Phabricator registration web page. Create an administrator account for daily management.

Now, let's have a look at how to configure Phabricator.

Step 10: Fix unresolved setup issues

Before you can use Phabricator with a peace of mind, you have to fix several setup issues. The number of setup issues varies, in my case, there were 16. Let's solve them one by one.

Issue 1: Base URI Not Configured

Click the "Base URI Not Configured" link to get into the issue details page in which you can learn more about this issue.

In order to fix this issue, you need to execute the following commands on your SSH terminal. Be sure to use the proper IP address.

cd /var/www/html/phabricator/phabricator/
sudo ./bin/config set phabricator.base-uri 'http://<your-Vultr-server-IP>'

Then in your web browser, click the "Reload Page" button on the issue details page. If your repair worked, the text on the page will become "Issue Resolved". Click the "Return to Open Issue List" link to investigate other issues.

Issue 2: No Authentication Providers Configured

Click the "No Authentication Providers Configured" link to get into the issue details page.

In order to fix this issue, you need to specify the authentication provider.

Click the "Auth Application" link and then the "+ Add Provider" button to get into the "Add Auth Provider" page. Choose an appropriate authentication provider, and then click the "Continue" button. Here I chose "Username/Password".

In the "Add Auth Provider: Username/Password" page, you can review more detailed settings, then click the "Add Provider" button.

You can add more authentication providers in the same fashion, but for now, click the "You have X unresolved setup issues..." link to handle other issues.

Issue 3: Phabricator Daemons Are Not Running

Click the "Phabricator Daemons Are Not Running" link to enter the details page.

In order to solve this issue, run the command below on your SSH terminal:

cd /var/www/html/phabricator/phabricator/
./bin/phd start

Click the "Reload Page" button to confirm the result.

Issue 4: PHP post_max_size Not Configured

Run the following commands on your SSH terminal to fix this issue:

sudo sed -i "s/post_max_size = 8M/post_max_size = 32M/" /etc/php.ini
sudo systemctl restart httpd.service

Click the "Reload Page" button to confirm your modifications.

There are six MySQL-related issues in total:

  • Small MySQL "max_allowed_packet"
  • MySQL STRICT_ALL_TABLES Mode Not Set
  • MySQL is Using Default Stopword File
  • MySQL is Using Default Minimum Word Length
  • MySQL is Using the Default Boolean Syntax
  • MySQL May Run Slowly

As a matter of convenience, let's fix them in one batch.

On your SSH terminal, edit the MySQL configuration file with vi:

sudo vi /etc/my.cnf

Under the three lines on the top:

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

Add the six lines below:

max_allowed_packet=32M
sql_mode=STRICT_ALL_TABLES
ft_stopword_file=/var/www/html/phabricator/phabricator/resources/sql/stopwords.txt
ft_min_word_len=3
ft_boolean_syntax=' |-><()~*:""&^'
innodb_buffer_pool_size=1600M        # about 40% of your system memory

Warning: You need to set a proper Innodb buffer pool size according to your specific server size. Usually, the Innodb buffer pool size should be about 40% of the amount of your machine's memory. For example, if you are using a machine with 4G memory, the reasonable Innodb buffer pool size would be 1600M. In case that you are using a machine with little memory (such as 768M), you may need to assign a size less than 40% of the amount of your machine's memory (say 220M) in order to save more memory for the system.

Save and quit:

:wq

Restart the MariaDB service:

sudo systemctl restart mariadb.service

Finally, run the following command:

mysql -u root -p -e "REPAIR TABLE phabricator_search.search_documentfield"

Click the "Reload Page" button to examine your efforts.

Issue 11: Install Pygments to Improve Syntax Highlighting

On CentOS 7, Pygments has been installed but not enabled by default, you need to enable it manually:

Click the link: Edit "pygments.enabled", Choose "Use Pygments" from the "Database Value" drop-down menu, then click the "Save Config Entry" button.

Issue 12: Server Timezone Not Configured

Modify the php.ini file:

sudo vi /etc/php.ini

Replace the line:

;date.timezone =

With:

date.timezone = America/Los_Angeles

Save and quit:

:wq

Note: "America/Los_Angeles" is the timezone value of my machine, you need to find the appropriate timezone value for your own server instance here.

Restart the Apache service:

sudo systemctl restart httpd.service

Click the "Reload Page" button to examine the result.

Issue 13: Large File Storage Not Configured

You need to deploy a proper large file storage solution according to your own setting. For now, you can click the "Ignore Setup Issue" button to skip.

Issue 14: Alternate File Domain Not Configured

Say you have set up an alternate file domain or a CDN, then in the SSH terminal:

cd /var/www/html/phabricator/phabricator/
sudo ./bin/config set security.alternate-file-domain <https://files.example.com>

Click the "Reload Page" button to examine the result.

Issue 15: Missing Repository Local Path

Use the following commands to solve this issue:

sudo mkdir /var/repo
sudo chown apache: /var/repo

Click the "Reload Page" button to examine the result.

Issue 16: PHP Extension 'APC' Not Installed

sudo yum install php-pear php-devel httpd-devel pcre-devel gcc make
sudo pecl install apc

During the installation process of APC, always press Enter to use the default option.

sudo vi /etc/php.ini

Add the four lines to the end of the file:

extension=apc.so
apc.write_lock = On
apc.slam_defense = Off
apc.stat = Off

Save and quit:

:wq

Restart the Apache service:

sudo systemctl restart httpd.service

Click the "Reload Page" button to check the result.

That's all. Happy coding!