Jon Allured

Computer Programmer, Whiskey Drinker, Comic Book Reader

Adding Additional Virtual Hosts to a Digital Ocean Server

published 09/16/16

The Apache Virtual Hosts tutorial for setting up your Digital Ocean server is really good, but when you want to add an additional site it's a little more than you need. To cut down on the clutter, I've written down my notes for what's required to setup additional sites.

Add Content

Start by creating the folder where your HTML content will live:

$ sudo mkdir /var/www/
$ sudo chown -R $USER:$USER /var/www/

Then fill that folder with whatever content you're planning on serving.

Site Configuration

Here's my basic configuration for a virtual server:

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
<VirtualHost *:80>
  DocumentRoot /var/www/

There are a TON more options, but that usually does the trick. Copy that over to your new site:

$ sudo cp /etc/apache2/sites-available/my-basic.conf /etc/apache2/sites-available/

And then replace the parts:

$ sudo vim /etc/apache2/sites-available/

Enable Site and Restart Apache

All that's left is to enable the new site and restart apache:

$ sudo a2ensite
$ sudo systemctl restart apache2