Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a LAMP server which hosts multiple sites. That server has a static IP address. What I would like to do is to point different domain names to different virtual hosts. For example:

Domain Names

Virtual Host Paths /var/www/sites/abc /var/www/sites/xyz

I would like to have point to the /var/www/sites/abc site and to point to the /var/www/sites/xyz site.

Is this possible? If so, what do I need to do from both an Apache and DNS configuration standpoint?

It is also worth noting my host is Linode.

Thanks in advance!

share|improve this question
up vote 3 down vote accepted

DNS: Set up each domain name to point to the same static IP address. Nothing else is required, there.

Apache: Turn on Name-based virtual hosts: NameVirtualHost *:80

Then for each virtual host:

<VirtualHost *:80>

        ServerAdmin <email address>

        DocumentRoot /var/www/sites/abc

        ErrorLog /var/log/apache2/abc/abc-error.log
        CustomLog /var/log/apache2/abc/abc-access.log combined


The log directives aren't required for virtual hosting, but I like to log access and errors separately for each vhost, and this lets you achieve that. (make sure the directory exists, though, or apache will fail to start).

Also, if you only want to enable virtual hosting on the one IP address replace *:80 with <ipaddress>:80 in the above.

See: for more info...

share|improve this answer

Yes. That's exactly what named based virtual hosts are used for.

share|improve this answer
Thanks, @schildwaechter! – Benny Nov 19 '10 at 14:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.