How to install Phabricator on Laravel Forge

I recently discovered Phabricator by Phacility, a powerful software development platform and decided to give it a go. In the past I used Redmine and I remember it was a pain to install for me as I did not have much experience in sysadmin. This time I have a bit more experienced and I have an ally with me: Laravel Forge.

Laravel Forge allows you to painlessly create and manage PHP 7.* servers which include MySQL, Redis, Memcached, and everything you need to run robust, modern Laravel Application.

Taylor Otwell, creator of Laravel & Laravel Forge

Step 1: Create a new server

I will use Digital Ocean as a server provider, but this should work all the same with AWS, Linode or anything.

If you don’t have a Digital Ocean account, this referral link will give you $100 free credit to start.

So, in your Forge dashboard select Digital Ocean and start configuring the server. I saw somewhere that it was recommended to have at least 2GB of RAM. I think it really depends on how many users you think you’ll have. In my case I’ll have less than 5 users so I’ll go with 2GB of RAM. If need be, the server can be resized later.

So in the form, select these settings :

  • Server Size : 2GB Ram – 1 CPU Core – 50GB SSD
  • PHP Version : 7.3 (latest as of today)
  • Database : MySQL 5.7

The rest is up to you. Choose a region close to your location.

My Server configuration

When everything is configured, click “Create Server” and wait a few minutes.

Step 2: Connect to the server

When the server is created, you receive an email from Forge with the server details.

What I like to do with new servers is add them to my local SSH config so that I can SSH into them using ssh server-name.

To do this, I edit the ~/.ssh/config file on my local machine and add these lines :

Host phabricator
Hostname 206.189.2.170
User forge
IdentityFile=/Users/webartisan/.ssh/id_rsa

If you have not yet created this file, at the top I also added some configuration for all my hosts.

Host *
AddKeysToAgent yes
UseKeychain yes
ServerAliveInterval 60

Save the file and type ssh phabricator in your Terminal

What you should see when you SSH into your Forge server for the first time

Step 3: Install Phabricator

In the installation guide they say to install Phabricator with git. But first I’ll create a new website with Forge so that all the domain mapping is done.

Go to your Forge dashboard and click on your server. On the “Sites” section, you’ll be able to add a new site. I’ll just go with phabricator.simondepelchin.be as a `General PHP / Laravel` project type and click “Add Site”.

Add a new Site where Phabricator will live

Now back on the server, if you type the command ls you should see the default site & your new site.

Go into your new site directory: cd phabricator.simondepelchin.be and delete the public directory that was created by default rm -f /public.

Now we’ll follow the installation guide. Type the following commands :

forge@phabricator:~/phabricator.simondepelchin.be$ git clone https://github.com/phacility/libphutil.git
forge@phabricator:~/phabricator.simondepelchin.be$ git clone https://github.com/phacility/arcanist.git
forge@phabricator:~/phabricator.simondepelchin.be$ git clone https://github.com/phacility/phabricator.git
After cloning the 3 repositories you should have something like this.

Now we’ll install APCu as they recommend it. On the server type the following commands.

sudo apt-get update
sudo apt-get install php-apcu
sudo ln -s /etc/php/7.3/mods-available/apcu.ini /etc/php/7.3/fpm/conf.d/30-apcu.ini
sudo ln -s /etc/php/7.3/mods-available/apcu.ini /etc/php/7.3/cli/conf.d/30-apcu.ini

This will install ACPu and symlink it into the PHP fpm & cli directories.

Step 4: Add a DNS Record

My DNS are managed by Cloudflare. I’ll just go and add a new A record that will point my domain (phabricator.simondepelchin.be) to the server IP (206.189.2.170).

DNS Record for Phabricator

Step 5: Configure the Web Directory & Nginx Server

When I created the site on Forge earlier I made a mistake. I left the Web Directory with the default value of /public but the right path is /phabricator/webroot. Just go to your site and click the “Meta” section and update the Web Directory.

Setup the Web Directory for Phabricator

Now if you go to your domain, you should see something. In my case it was an error.

Request parameter '__path__' is not set. Your rewrite rules are not configured correctly.

This issue happens because the default nginx configuration that has been generated by Laravel Forge doesn’t really work for Phabricator.

We’ll need to update the Nginx Configuration. Good for us, at the bottom of the page on Laravel Forge there is a “Files” button with a “Edit Nginx Configuration” option that let us edit the configuration directly from the interface. No need to search in the server!

I’ll just change one line. Remove the following line.

try_files $uri $uri/ /index.php?$query_string;

And replace it with this one.

rewrite ^/(.*)$ /index.php?__path__=/$1 last;

Click “Save”. Laravel Forge will automatically reload the Nginx Server so a few seconds later you can refresh your domain and you should see another error.

This means Nginx works correctly now.

Step 6: Configure the MySQL connection

You probably figured that the latest issue is due to the MySQL connection not being set up correctly. Of course we didn’t do anything so the app doesn’t know where to connect.

I’ll use the forge user created by default by Forge. This user has all rights so we should not run into any issue.

Now, all we need to do is follow the instructions given in the error screen.

On the server, go to the phabricator directory ~/phabricator.simondepelchin.be/phabricator and type the following commands with the correct values. (You’ll find the password in the email Forge sent you upon server creation)

./bin/config set mysql.host 127.0.0.1
./bin/config set mysql.port 3306
./bin/config set mysql.user forge
./bin/config set mysql.pass **********

When all is configured, you’ll be able to run the following command.

./bin/storage upgrade

Just answer y to the prompts or use the `–force` flag.

You’ll see a bunch of lines in the terminal and after a while you should see some reassuring messages.

What you should see if everything went well.

Step 7: Create Admin account

If you refresh the website you should be able to create your admin account and sign into the app.

Great! That’s it.

Step 8: Add a Let’s Encrypt Certificate

I don’t like seeing the “Not Secure” in my brower next to my domain name. So in Forge I’ll add a Let’s Encrypt certificate.

Go to your Forge Dashboard, click on the server, then click on your site. Go to the SSL section.

Select “LetsEncrypt” as the provider and click on “Obtain Certificate”.

Wait for a few secs while the certificate is being installed and after that refresh your website.

All done!


Conclusion

Thanks for following along me for this tutorial. I hope you all were able to install Phabricator without any issue.

I’ll take some time to review the app myself and see if it meets my needs.

If you have any question or suggestion, feel free to comment below.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.