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!
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:
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...
Yes. That's exactly what named based virtual hosts are used for. http://httpd.apache.org/docs/current/vhosts/name-based.html