Create Your Own Software Development Platform using Phabricator on CentOS 7
Phabricator is a free and open source collection of web applications that helps you to build your own software development platform for better software. Phabricator is ideal when you are working with multiple teams for software development. It is built using PHP and uses MySQL to store its data. Phabricator gives you a box of solid tools for a comparatively small setup cost. It is extremely fast and the tools are easy to learn and use. The major components of Phabricator are:
- Differential, a code review tool
- Diffusion, a repository browser
- Maniphest, a bug tracker
- Phriction, a wiki
In this tutorial, we will install and configure Phabricator on an Alibaba Cloud Elastic Compute Service (ECS) CentOS 7 server.
- You must have Alibaba Cloud Elastic Compute Service (ECS) activated and verified your valid payment method. If you are a new user, you can get a free account in your Alibaba Cloud account. If you don’t know about how to set up your ECS instance, you can refer to this tutorial or quick-start guide. Your ECS instance must have at least 1GB RAM and 1 Core processor.
- A domain name registered from Alibaba Cloud. If you have already registered a domain from Alibaba Cloud or any other host, you can update its domain nameserver records.
Update Your System
We recommend you to install any new package on a freshly updated ECS server. You can upgrade all the available packages using the following command.
yum -y update
Install LAMP Stack
Once the system is updated, you can start the LAMP installation by installing Apache web server, MariaDB which will be used to store data and PHP with required modules. Execute the following command to install apache server and MariaDB.
yum -y install httpd mariadb-server mariadb mod_ssl
We will install PHP version 7.1. The default yum repository contains PHP version 5.4, so you’ll need to first add the EPEL repository and then install PHP version 7.1.
yum -y install epel-release
Next, install the Webtatic repository using the following command.
Run the following command to install PHP 7.1 with required modules.
yum -y install php71w php71w-cli php71w-mysqli php71w-gd php71w-mbstring php71w-curl php71w-iconv php71w-pcntl php71w-opcache
Next, you’ll need to edit the configuration in
php.ini file using any text editor. Here we are using nano text editor, you can also install it using
yum -y install nano.
Next, find the following lines in the file and change the memory limit to the highest amount.
; Maximum amount of memory a script may consume (128MB)
memory_limit = 128M
Next, find the following lines in the file and change the timezone according to your region and uncomment the line.
; Defines the default timezone used by the date functions
Next, find the following lines and set their values according to instructions provided.
post_max_size = 8M #Change it to at least 32M
upload_max_filesize = 2M #Change it to at least 32M
Save the file and exit from the text editor.
Start the Apache web server and enable it to automatically launch at boot time, using the following command.
systemctl start httpd && systemctl enable httpd
Similarly, start the MariaDB and enable it to launch at the boot time.
systemctl start mariadb && systemctl enable mariadb
Now, let’s make sure to harden the security of MariaDB installation. Execute the following command.
You will be asked to enter root password and press Enter button for none and proceed further. Answer Y to all the question asked and complete the process.
Enter current password for root (enter for none): Enter
Set root password? [Y/n]: Y
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
You will need to install Git and to do so run the following command.
yum -y install git
You have installed all the dependencies required to install the Phabricator. Now you are ready to install it from git. Create a new directory and change your current directory to that directory using the following commands.
mkdir /var/www/phabricatorcd /var/www/phabricator
Clone the required Phabricator files using the following commands.
git clone https://github.com/phacility/libphutil.gitgit clone https://github.com/phacility/arcanist.gitgit clone https://github.com/phacility/phabricator.git
Next, you’ll need to setup the database credentials. Execute the following commands one by one and they will do the job for you.
cd /var/www/phabricator/phabricator/./bin/config set mysql.host localhost./bin/config set mysql.port 3306./bin/config set mysql.user root./bin/config set mysql.pass <MySQL-root-password>
Populate the phabricator scheme using the following command.
./bin/storage upgrade --user root --password YourMariaDBPssword
You’ll be asked the following questions, press Y to continue.
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...
You should see the following result as output.
Completed applying all schema adjustments.
ANALYZE Analyzing tables...
ANALYZED Analyzed 510 table(s).
Next, change the ownership rules for the file to the Apache web server. Run the following command to do so.
chown -R apache:apache /var/www/phabricator
It is recommended to use SSL for accessing Phabricator application through the web interface. Now we will need to generate SSL certificates from Let’s Encrypt client. You can use commercial SSL certificates instead, you can purchase SSL certificates from Alibaba Cloud.
Now, temporarily stop the Apache web server for installing Certbot using the following command.
yum -y install python-certbot-apache
Next, execute the following command to obtain SSL certificates. Make sure that your domain is pointed to the server.
certbot certonly --standalone -d yourdomain.com
It may ask you which SSL configuration to use during authentication, choose
ssl.conf. All the changes made to the file will be automatically restored. Finally, provide your email address and accept the terms and condition. Once the certificates are generated, they are likely to be stored in the following directory.
In the directory, you will find
fullchain.pemwhich is your domains certificate and
privkey.pem which is your certificate's private key.
Let’s Encrypt SSL certificates expires in 90 days, so we recommended you to set an automatic renewal for your certificates. Run the following command to open your crontab file.
Add the following line to the file.
30 1 * * 1 /usr/bin/certbot renew >> /var/log/le-renew.log
Create a Virtual Host
Create a new virtual host file for Phabricator using the following command.
yourdomain.com with your actual domain. Now add the following content into the file.
Redirect permanent / https://yourdomain.com/
RewriteRule ^/rsrc/(.*) - [L,QSA]
RewriteRule ^/favicon.ico - [L,QSA]
RewriteRule ^(.*)$ /index.php?__path__=$1 [B,L,QSA] <Directory /var/www/phabricator/phabricator/webroot>
Require all granted
In the above configuration change
yourdomain.com to your actual domain.
Finally, restart the apache server and MariaDB to apply all the changes that we just configured. You can do so using the following commands.
systemctl restart httpdsystemctl restart mariadb
You will need to disable SELinux otherwise, Phabricator won’t be able to connect to the database. To temporary disable SELinux without restarting the server, run the following command.
Open up your favorite web browser and visit https://yourdomain.com. Replace
yourdomain.com with your actual domain name and you will see the following screen to set up an administrator account.
Provide the administrators details asked like username, password, and email then click Create Admin Account button. You will be now taken to your administrative dashboard.
You will need to configure a few things before you can use the Phabricator application for the production environment. First of all, start the Phabricator daemon using the following command so that Phabricator can do the required background tasks.
cd /var/www/phabricator/phabricator/./bin/phd start
Next, configure the Base URI using the following command. It is important to configure the Base URI as most of the features in the application will be unavailable unless Base URI is configured.
cd /var/www/phabricator/phabricator/./bin/config set phabricator.base-uri 'https://yourdomain.com'
Set the local repository path using following command.
mkdir /var/repochown -R apache:apache /var/repo
Now Phabricator is completely configured and you can manage your web application from the administrative dashboard. You can add new repositories by clicking on Create Repository button.
You can review your application code using Differential component of Phabricator available on the left side of web page. You can browse all repositories using Diffusion component of Phabricator.
Congratulations! You have successfully installed Phabricator on your Alibaba Cloud Elastic Compute Service (ECS) CentOS 7 server. Now you can deploy your own software development platform using Phabricator.