This guide will walk you through the basic setup of using the older Apache 1.x web server.
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’s Plus Managed DNS service to be able to do just that. We assume that you have already installed the Apache server on your Windows or Unix/Linux machine and have gotten it to run.
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
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:wwwerror_log # error log file
TransferLog c:wwwaccess_log # access log file
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:wwwsomeothernamewww
ServerName someothername.com
ServerAlias www.someothername.com
ErrorLog c:wwwsomeothernamelogserror_log
TransferLog c:wwwsomeothernamelogsaccess_log
To add the third domain name, just continue as illustrated below.
############# THIRDDOMAINNAME.COM ############
ServerAdmin webmaster@thirddomainname.com
DocumentRoot c:wwwthirddomainnamewww
ServerName thirddomainname.com
ServerAlias www.thirddomainname.com
ErrorLog c:wwwthirddomainnamelogserror_log
TransferLog c:wwwthirddomainnamelogsaccess_log
To add virtual hosts or domain names, just create additional virtual host entries in your httpd.conf file based on the examples above.