ada recommended color contrast radios be damned

Apache Virtual Hosts On Ubuntu

Apache is a free, open source web server software that powers around two-thirds of all websites in the world – and about a third of all websites are running WordPress.

The post walks you through the process of installing the Apache software and setting up Apache virtual hosts so that you can run more than one website on the same server.

Setting Up Apache Virtual Hosts On Ubuntu

SSH into the web server with an SSH key pair:

ssh -i ~/.ssh/supernifty supernifty@143.198.116.106 RETURN

Get a list of updates for all the software that’s currently installed on the server:

sudo apt update RETURN

Install the Apache web server software:

sudo apt install apache2 RETURN

Create public html directories for each site:

sudo mkdir -p /var/www/supernifty.com/public_html RETURN

sudo mkdir -p /var/www/25monkeys.com/public_html RETURN

This is where all your website files will reside.

Change the ownership to everything in the /var/www directory to your own user so that all the permissions for everything you’re about to create are set properly:

sudo chown -R supernifty:supernifty /var/www RETURN

Create a placeholder html file for each site so that when someone visits the site with a web browser before you’ve set up the actual website they won’t get an error:

echo ‘future home of supernifty.com’ > /var/www/supernifty.com/public_html/index.html RETURN

echo ‘future home of 25monkeys.com’ > /var/www/25monkeys.com/public_html/index.html RETURN

Dupe the default Apache config file. It’s faster than retyping everything:

sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/supernifty.com.conf RETURN

Open the nano text editor to edit the newly duped config file:

sudo nano /etc/apache2/sites-available/supernifty.com.conf RETURN

and make your file look something like this:

<VirtualHost *:80>
ServerAdmin hello@supernifty.com
ServerName supernifty.com
ServerAlias www.supernifty.com
DocumentRoot /var/www/supernifty.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Once you’ve finished editing, save your changes and exit the nano text editor by hitting CONTROL-O RETURN and CONTROL-X

Dupe the edited config out to the other domain:

sudo cp /etc/apache2/sites-available/supernifty.com.conf /etc/apache2/sites-available/25monkeys.com.conf RETURN

and edit the duped config file for the second domain name, in this case just replacing all instances of supernifty.com with 25monkeys.com.

Enable the config file for each site:

sudo a2ensite supernifty.com.conf RETURN

sudo a2ensite 25monkeys.com.conf RETURN

Disable the default Apache config:

sudo a2dissite 000-default.conf RETURN

Restart Apache for your changes to take effect:

sudo systemctl restart apache2 RETURN

Once you’ve completed the steps above and have pointed your domains at your server’s IP address at your domain registrar, you should see the ‘future home of supernifty.com’ and ‘future home of 25monkeys.com’ text you created in the placeholder html files when you visit your domains in a web browser.

Now it’s time to install SSL certificates with CertBot.