Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 abc.com xyz.com

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

I would like to have abc.com point to the /var/www/sites/abc site and xyz.com 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
add comment

2 Answers

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>

        ServerName abc.com
        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

</VirtualHost>

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: http://httpd.apache.org/docs/current/vhosts/ for more info...

share|improve this answer
add comment

Yes. That's exactly what named based virtual hosts are used for. http://httpd.apache.org/docs/current/vhosts/name-based.html

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

Your Answer

 
discard

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.