Adding Apache2 to Ubuntu 16.04.02

Initial installation of Apache2 to a DigitalOcean Ubuntu 16.04.02 Server is fast and easy

# apt install apache2
# apache2ctl configtest
# vi /etc/apache2/apache2.conf

# apache2ctl configtest
# systemctl restart apache2

One last thing before testing, let’s open up the firewall

# ufw allow proto tcp from any to any port 80,443

Browsing to the server hostname or IP address you should see a screen that starts out like this:

Configuring Apache VirtualHosts

I like to make a new directory for the virtual hosts

# cd /; mkdir www

Make the following changes

# vi /etc/apache2/apache2.conf

Move index.php to be first

# vi /etc/apache2/mods-enabled/dir.conf

# systemctl restart apache2

Copy the virtual host file

# cd /etc/apache2/sites-available
# cp -a 000-default.conf name-of-virtual.openuptown.net.conf

Make appropriate changes

# vi name-of-virtual.openuptown.net.conf

Enable the site

# a2ensite name-of-virtual.openuptown.net.conf

Reload Apache and bam!

# systemctl restart apache2

Thanks!
-Yehuda