I recently had a request from someone on how to setup multiple domains on a single IP address. This is something that I’ve thought about doing before, but haven’t taken the time to stop and set it up. After getting sub-domains working, this was a breeze, as it’s the same process. I’m working on an Ubuntu server, so this may be a little different for you.


First setup the DNS, since it will probably take about an hour for that to update anyway, depending on the TTY that you use. If you’re setting this up and you want to make sure it works, you can edit your /etc/hosts file on a mac or linux machine. I think there’s a way to do this in windows as well, but I’m not sure of what file you’d be looking for. Just remember to delete that entry after you know it works.

To setup the DNS you first need to find the DNS control for the domain registrar that you use. In GoDaddy the option would be called Total DNS. Change the A record to the IP address you want to use as a server and you’re done.


Now you need to create a new file in /etc/apache2/sites-available/. Call it whatever you want. I will call it NEWSITE.TLD. In this file you will create a new file that looks similar to this, only substituting information specific to your server:

NameVirtualHost *:80

	ServerAdmin you@your-domain.tld
	ServerName your-domain.tld

	DocumentRoot /var/www/your-root/
		Options Indexes FollowSymLinks MultiViews
		AllowOverride None
		Order allow,deny
		allow from all

	ErrorLog /var/log/apache2/error.log
	LogLevel warn
	CustomLog /var/log/apache/access.log combined
	ServerSignature On

Now we enable the site with:

sudo a2ensite /etc/apache2/sites-available/NEWSITE.TLD

Reload the apache configuration and you should be good to go.