scriptygoddess

16 Sep, 2002

Apache Virtual Hosts

Posted by: dave In: Lessons learned

This is really for Web Admins, but someone may be interested…
This is kinda in response to a posting on Jenn's site, but if anyone out there works at all with Apache, do yourself a favor and learn how to use the Virtual Host tags in the httpd.conf file. You can avoid so many "low level" network issues if is configured correctly. An example:

I use the following VH tags to set up name based virtual hosts to tie different names into different IP addresses:
<VirtualHost *>
ServerName netstat.wpsweb.net
DocumentRoot /var/www/htdocs/phpBB2
</VirtualHost>

This lets me set up a host on my server, and any request to netstat.wpsweb.net is resolved to the given DocumentRoot, and others are passed on to other VHs. (Its not a bad idea to set up a default VH to point to your default DocRoot) This name based hosting is very useful. Other directives can be placed in the VH tags (say different logging options) and only have them effect my test site. Lots more information in the Apache Docs.

I put this under "Lessons learned", mainly because I spent quite a bit of time running around the httpd.conf file until I learned to harness the VH tags. Anything put in the rest of the httpd.conf file globally effects your sites, but with VH you can fine tune a small portion of your web deployment, then if you like the changes you can roll them out to the entire server.

I make a lot of logging changes in VH tags, so when I debug site problems I can access lots of info, but when the site is deployed I can cut back the logging to a standard format.

I have not run a server with lots of Virtual Hosts, and if you were doing any web site hosting I could see VHs getting out of hand, esp. if you are making customizations to each…

In the end, I find them useful for keeping IPs unlinked from a specific site, and a great way to debug web server issues for a site without globally affecting all your other sites.

2 Responses to "Apache Virtual Hosts"

1 | Nathan

September 22nd, 2002 at 10:45 pm

Avatar

Thank you so much, I've recently became my own SysAdmin and was trying to figure the multiple domains thing out, this is a great help. I've been scouring the ApacheDOCS looking.

2 | David

March 24th, 2003 at 12:59 pm

Avatar

thanks a lot, i was having some problems getting a directory to display php documents to users outside my private network, this helped a ton.

Featured Sponsors

Genesis Framework for WordPress

Advertise Here


  • Scott: Just moved changed the site URL as WP's installed in a subfolder. Cookie clearance worked for me. Thanks!
  • Stephen Lareau: Hi great blog thanks. Just thought I would add that it helps to put target = like this:1-800-555-1212 and
  • Cord Blomquist: Jennifer, you may want to check out tp2wp.com, a new service my company just launched that converts TypePad and Movable Type export files into WordPre

About


Advertisements