setting up subdomain on ubuntu server

I have a server at Everything is working fine and I have a blog and owncloud that I access writing and
Now, I want to create subdomains so that I can write and

I have looked a lot into it and the simplest tutorial was this one which I followed.
Except that I am not on my server but ssh into it remotely so if I use localhost I cannot see if this works I believe. This is my first obstacle, can I follow this tutorial without being present next to the server?

I also just discovered CNAME records which (I am not completely sure) seem necessary to what I want to do. I use and I have tried to follow something like this but this is not really clear either

Does anyone have any pointers? This is quite shady to me and I have no idea if I am far from the solution or really close (at least if I could try localhost that would be a first step in order to check my Apache conf but I can’t even do it since I ssh).

Anyways, thanks for your help in advance. Any help, link is welcomed.

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

This is actually really easy.

First make sure your DNS is working. You can use a A, AAAA or CNAME record as long as it points to your IP address.

Please check if it’s working before you continue! This will save you much trouble. You can check using ping or nslookup If it’s pointing to your IP address you’re good.

Note that DNS changes may take up to 24 hours. If you want to continue now, you can edit your hosts file to manually add the sub domain. Note that this will only work for your current PC so you should check your DNS again 24 hours later to make sure it’s working elsewhere as well (don’t forget to revert your changes to your hosts file before you check).

To do this:

sudo nano /etc/hosts

add line like (replacing the IP and hostname of course):

and save the file.

Now update your Apache2 configuration.

Just adding this VirtualHost will do:

<VirtualHost *:80>
    DocumentRoot /var/www/

Now create /var/www/ and restart Apache2:

mkdir -p /var/www/
sudo service apache2 restart

enable the site:

sudo a2ensite

Repeat this for every sub domain you want to add.

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply