0

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!

3

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...

1

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

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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