Wednesday, October 9, 2019

H2B SOTU-db Step 3: Apache

This series of posts documents the process of getting SOTU-db back online after losing access to the LUC servers upon which it was originally hosted.

Now that I've got my VM provisioned and running R, the next step is to turn it into a web server by installing Apache. The goal for the completion of this step will be to visit and have it display a basic HTML page, which I'll use to post a temporary notice the SOTU-db is offline for now. 

Before I do that, I'm going to activate UFW, the Uncomplicated Firewall by following the steps on this Digital Ocean Ubuntu setup guide (starting with Step Seven). It's pretty... uncomplicated, so I won't go into detail here. Basically, I'm just allowing OpenSSH connections from anywhere for now, then after installing Apache we'll give it permissions as well. It looks like activating UFW this was successful, so I'll move on.

Fortunately, Apache is extremely popular and is easy to access from the standard Ubuntu package repositories. Installation should be as simple as:
sudo apt update
sudo apt install apache2
And indeed, the installation process went very smoothly. However, I was frustrated to see that I couldn't seem to access the "It works!" page that was supposed to be generated as part of the install. The file is in /var/www/html on the VM like it's meant to be, and I added "Apache Full" to the UFW allow-list. After some running around in circles, I eventually realized that I had left blank two checkboxes in the Google Compute Engine dashboard for my instance: under a small section called "Firewalls," I had left "allow HTTP traffic" and "allow HTTPS traffic" unchecked. So, I don't think my requests were ever even reaching my VM. Once I checked those boxes and restarted the VM, I had no problem accessing the "It works!" page.

Next, I opened up Atom and wrote a quick new index.html file, letting users know that SOTU-db is down and directing them to the dev blog.

I also promoted the VM's public IP address from an ephemeral to a static IP, then went into my Google Domains dashboard and added an A record linking the domain to that IP. This way, is connected to my VM and, unlike with the old LUC VM, should allow "sotu-db" to remain in the address bar as long as a user is on the site (instead of being redirected to like previously).

So, we're now up and running with
1. a VM
2. R installed
3. a static page served to visitors to Try it out!

Next steps will be to begin migrating the project data itself onto the server!