×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

VirtualHosts

How to set up Name Based Vitualhosts on Apache. by Wullie
Posted: 25 Apr 02 (Edited 23 Aug 03)

This explains how to use Namebased Virtualhosts on Apache 1.x. The following will also keep seperate logs for each Virtualhost, if you do not want this and you want all domains logs to be combined then remove the log entries in the virtualhost directives.

Uncomment    

BindAddress *

Also uncomment

NameVirtualHost *

Then at the bottom (This makes it easier to find in the future) of the httpd.conf, add the following lines.. The lines starting with a # are comments and can be removed.

<VirtualHost *:80>
   UseCanonicalName off
# Your domain name.
   ServerName domain.co.uk
# Any variation of your domain name.
   ServerAlias www.domain.co.uk
# Email address of server admin
   ServerAdmin webmaster@domain.co.uk
# Location of the sites files
   DocumentRoot /www/domain
# Location of your cgi-bin
   ScriptAlias /cgi-bin/ "C:/www/domain/cgi-bin/"
# Location of the sites log files
   ErrorLog logs/domain/error.log
   CustomLog logs/domain/access.log common
   CustomLog logs/domain/referer.log referer
   CustomLog logs/domain/agent.log agent
# Add email to server generated files
   ServerSignature EMail
</VirtualHost>

Just repeat this for each domain.

It will look something like the following:


<VirtualHost *:80>
   UseCanonicalName off
   ServerName domain.co.uk
   ServerAlias www.domain.co.uk
   ServerAdmin webmaster@domain.co.uk
   DocumentRoot /www/domain
   ScriptAlias /cgi-bin/ "C:/www/domain/cgi-bin/"
   ErrorLog logs/domain/error.log
   CustomLog logs/domain/access.log common
   CustomLog logs/domain/referer.log referer
   CustomLog logs/domain/agent.log agent
   ServerSignature EMail
</VirtualHost>
<VirtualHost *:80>
   UseCanonicalName off
   ServerName domain1.co.uk
   ServerAlias www.domain1.co.uk
   ServerAdmin webmaster@domain1.co.uk
   DocumentRoot /www/domain1
   ScriptAlias /cgi-bin/ "C:/www/domain1/cgi-bin/"
   ErrorLog logs/domain1/error.log
   CustomLog logs/domain1/access.log common
   CustomLog logs/domain1/referer.log referer
   CustomLog logs/domain1/agent.log agent
   ServerSignature EMail
</VirtualHost>


The first in the list is the default that is called if Apache doesn't recognise the server name.

If you decide to use seperate logs for each domain then to save yourself getting errors with the above added, make sure that the directories that are specified for the error logs exist..


Hope this helps

Wullie

sales@freshlookdesign.co.uk
www.freshlookdesign.co.uk

Back to Linux (server) FAQ Index
Back to Linux (server) Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close