Apache Virtual Hosts

Having figured out how to compile and install Apache I now need to configure it!!

To get the most for my money I am going to be hosting several domains on the one apache install. To do this with 1 IP address you need to use the VirtualHost directive.

I have tried to set this up using Webmin, (more on that another time), and had some limited success. The trouble was although it created my new domain, I couldn’t then access the root domain of the server, as it was being forwarded to the new virtual host. A tad annoying as I had a phpMyAdmin install in the root folder which I could then no longer access.

So a quick trip to google gave me a few answers and a quick and dirty Apache config file 101 lesson. It was much easier than I thought.

There were several things that Webmin hadn’t sorted out, now I am pretty sure it could have sorted them out I just didn’t know I had to set these options in the first place so I don’t think its Webmins fault. Anyway, I had to set the server name for the Apache install to be the fully qualified domain name of my server. I then needed to add in a VirtualHost directive for the FQDN too:

ServerName www.mydomainname.com

ServerPath /

DocumentRoot /usr/local/apache/htdocs

Once that was in and Apache was restarted we were up and running!!