How to setup Phabricator on AWS (Part 2 — Launching Phabricator)
Summary
During the last part of the walkthrough we set up the requirements needed in order to deploy an instance of Phabricator on AWS EC2. We also configured the DNS settings and mailer so that we are able to connect it once Phabricator is installed. If you missed out on these steps, you can revisit them here:
Part 1 — Setting up requirements
In this second part of the walkthrough we will install Phabricator onto our AWS EC2 instance and set it up for further configuration. If you already have this part setup, you can skip to the next part of the walkthrough here.
Installing Phabricator and Dependencies
This walkthrough follows the basic steps outlined in Phabricator’s installation instructions, fortunately the installation can be done using one of the scripts provided. This walkthrough will be using the Ubuntu version of the installation script since the instance we spun up in Part 1 runs on Ubuntu Server 18.04. This means that our Phabricator installation will be LAMP (Linux, Apache, MySQL, PHP) application. If you would like to use a different webserver, Phabricator provides instructions to use alternatives such as Nginx, lighttpd, or others.
To use this script, first login to your AWS instance with the SSH key you obtained from creating it earlier. Once logged in, create a new file with the title ‘install_ubuntu.sh’ and paste the following into it.
Once you have created the necessary file, make it executable with the command:
sudo chmod +x install_ubuntu.sh
then run the file with
./install_ubuntu.sh
You will have to answer yes to a few of the options but once the installation is done, you should receive a message saying that the installation has completed successfully.
Configuring Apache
After installing the necessary components to host Phabricator, the next step is to follow the instructions outlined in the configuration guide. Since we have installed Phabricator using the provided script, we will be following the steps outlined for Apache.
First create a file with the name ‘httpd.conf’ under ‘/etc/apache2/’ with command:
sudo vim /etc/apache2/httpd.conf
and paste in the following:
Be sure to replace all the value for ‘MYDOMAIN’ with the value for your own domain. This file will set up the configuration for apache to serve phabricator over HTTPS.
You will then need to change the ‘apache2.conf’ file to import and use the settings provided in this file. This can be done by editing the file with command:
sudo vim /etc/apache2/apache2.conf
and entering the following line:
Now in order for Apache to serve Phabricator with the configurations you entered, you will have to remove the default config under ‘/etc/apache2/site-enabled/’. This can be done with the command:
sudo rm /etc/apache2/sites-enabled/000-default.conf
Configuring HTTPS
Now we should configure SSL for our Apache server so that it runs under HTTPS and not HTTP. If you like to read more on the difference between the two, I recommend reading this guide. The process of using HTTPS has been simplified so that it can be done and renewed automatically using certbot. Here are some of the basic commands that you’ll have to follow to install and activate certbot.
sudo apt-get update
sudo apt-get install software-properties-common -y
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install certbot python-certbot-apache -y
sudo certbot --apache
The installation and setup process provided there is rather straight forward and once setup correct you should see something like this.
Do a dry run of the certbot to verify that it installed correctly.
sudo certbot renew --dry-run
After setting up the certbot, change your ‘httpd.conf’ file to now look like this:
Once this is done, you should also restart apache service with the command:
sudo service apache2 restart
Configuring MySQL
Once you have setup HTTPS for your webserver you should notice that if you tried to access your site you will be prompted with a page that looks similar to this.
This issue can be resolved using the steps outlined in the stackoverflow post linked here. The gist of it is that you need the root user to use the ‘mysql_native_password’.
This can be done with the following commands:
sudo mysql -u root
You should now be entered into the MySQL console (mysql>)
USE mysql;
UPDATE user SET plugin='mysql_native_password' WHERE User='root';
FLUSH PRIVILEGES;
exit;
You should now be out of the MySQL console
sudo service mysql restart
Once this is configured, you should now be able to access the Phabricator Admin page and can go on configuring Phabricator.
Troubleshooting
If after you configured SSL and you continue to see this page rather than any page put out by Phabricator, these steps may help you.
First navigate check to see if you have the ‘httpd-le-ssl.conf’ file under ‘sites-enabled’ folder.
ls /etc/apache2/sites-enabled/
Now look into the contents and make sure that it looks something like this: