Hosting Multiple Domains with Apache and No-IP™
Many people would like to host more than one website on their Apache server but think they can't because they
only have one IP address. This guide will show you how to use the name-based virtual hosts feature of Apache
in conjunction with No-IP Plus Managed DNS service to be able to do just that.
This guide is based on the assumption that your web server is already configured to answer to all requests for "yourdomainname.com."
We will refer to this as your primary domain name; all other domain names will be referred to as "virtual hosts".
If you don't already use Apache as your web server but would like to, you can
refer to our existing guide "How to setup an Apache web server, Using your own domain name and
No-IP Plus service." Please bear in mind that we are offering these guides for informational purposes only and are not responsible for offering technical support
for Apache or any other third party software you may be using. There is documentation that ships with Apache that will more fully explain how to configure
and use your software and you should refer to that for additional assistance with these concepts. Apache also has their documentation available online.
First, make a copy of your httpd.conf file for security reasons. If your Apache
service fails to start with the modified file you can then use your backup to get the server up and running while you look for the error.
Open your httpd.conf file in a standard text editor and find 'Section 3: Virtual Hosts'. You should see something like this:
NameVirtualHost *
Edit this line by adding your servers "primary domain name" instead of the asterisk:
NameVirtualHost yourdomainname.com
Now, let's add our first virtual host:
Let's start by configuring your server to answer requests for "www.yourdomainname.com";
"www" in front of the domain name is also considered to be a virtual host or it can sometimes be referred to as a subdomain. This hostname is not configured automatically by Apache.
It is good to comment your changes (the "#" symbol denotes a comment and is ignored by the Apache software), so you can debug problems or remember why you made certain changes at a later date.
Add the following code, customized for your own domain and document paths of course, to the httpd.conf file after the NameVirtualHost line:
############# YOURDOMAINNAME.COM ############# primary domain name ServerAdmin webmaster@yourdomainname.com # webmasters email address DocumentRoot c:\www # root for your 'www' content ServerName yourdomainname.com # your full domain name ServerAlias www.yourdomain.com # the 'www' virtual host ErrorLog c:\www\error_log # error log file TransferLog c:\www\access_log # access log file
Before you edit your server file locally, make sure that you have already
added these new domain names to your No-IP Plus account. Note that when you register or add a new domain name to your No-IP account,
it may take sometime for the new domain name to be propagated to the web (24 to 48 hours is typical).
In order to add these additional virtual hosts, simply insert them into your httpd.conf file below the code we created in the first example.
############# SOMEOTHERNAME.COM ############ServerAdmin webmaster@someothername.com DocumentRoot c:\www\someothername\www ServerName someothername.com ServerAlias www.someothername.com ErrorLog c:\www\someothername\logs\error_log TransferLog c:\www\someothername\logs\access_log
To add the third domain name, just continue as illustrated below.
############# THIRDDOMAINNAME.COM ############ServerAdmin webmaster@thirddomainname.com DocumentRoot c:\www\thirddomainname\www ServerName thirddomainname.com ServerAlias www.thirddomainname.com ErrorLog c:\www\thirddomainname\logs\error_log TransferLog c:\www\thirddomainname\logs\access_log
Save your new httpd.conf file and restart Apache. Please make sure that the disk paths to your content are correct. If they're not it could cause your pages not to be displayed or even prevent the Apache server from starting up normally. If everything's fine, you should be able to access your 'www' content by typing www.yourdomainname.com in your url field. It's always a good idea to save the httpd.conf file often and restart your server to make sure that the new config file is accepted by the server without errors.
To add virtual hosts or domain names, just create additional virtual host entries in your httpd.conf file based on the examples above.