A quick guide that will show you how to host multiple websites on a single Digital Ocean droplet. This is really useful for starter websites that have little to no traffic. You can save a lot of money on hosting by running a virtual host $5 droplet with LAMP on Ubuntu 16.04. I use this setup to build and sell starter sites on Flippa.
First create a $5 droplet running LAMP on Ubuntu 16.04 and ssh into the droplet via terminal or putty. If you already have a Digital Ocean account, you have probably already done this before, if you haven´t just login to Digital Ocean and click “Create Droplet”, selecting “One Click Apps”, LAMP on 16.0.4, the first $5 droplet listed, choose any region and click the green “Create” button at the bottom.
If you haven´t got an account, use this link here to get $100 free credit https://m.do.co/c/c08a36ec894f
So logged into the droplet via SSH we enter the following commands and repeat per domain / website you want to host on the droplet.
sudo mkdir -p /var/www/YOURDOMAIN/public_html
sudo chown -R $USER:$USER /var/www/YOURDOMAIN/public_html
sudo chmod -R 755 /var/www/YOURDOMAIN/
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/YOURDOMAIN.conf
sudo nano /etc/apache2/sites-available/YOURDOMAIN.conf
- Add the following 2 lines:
Make sure it looks exactly as below, you need to change 2 lines and add the 2 lines above.
sudo a2ensite YOURDOMAIN.conf
sudo systemctl restart apache2
- Done! Just make sure you have setup DNS records to point the domain name at the server.
The public directory of your website cab be found at /var/www/YOURDOMAIN/public_html/
I use WordPress for most of my sites, if you would like to learn how to install WordPress on your newly created virtual host droplet, I have written a quick a guide here.