The Race
A TV show pitting so called celebrities against each other in a battle of the sexes to find out whcih gender makes the best drivers. Or at least thats what »
Your mac is set up and ready to go, but how exactly do you go about setting Apache up in OS X Leopard these days? Well it's it a bit more like linux now with the demise of Network Manager (I think thats what it was called, been a while since I used tiger), but its not too hard, honest!
Firstly decide what suffix your going to use for your local machine, be sensible and use something meaningful like .local or .dev. Dig out your apache vhost file (httpd-vhosts.conf) and set up the file.
You will need a line such as “NameVirtualHost *:80” to make sure any web connections are picked up. Now create you first virtual host a bit like this:
<VirtualHost *:80>
DocumentRoot /Users/username/Sites/sitename/docroot
ServerName mysite.local
<Directory "/Users/username/Sites/sitename/docroot">
AllowOverride All
Options All
</Directory>
</VirtualHost>
Once you have saved this file (root/admin privilleges are required) you will need to restart Apache so it reloads you config files. You can do this by starting up terminal and typing “sudo apachectl graceful” and entering the root/admin password.
Now type mysite.local in to your browser of choice and see what happens.... Nothing is the answer. At this point Apache knows it should be looking for a request a site called mysite.local but your machine has no idea what .local means.
To fix this you have to edit you /etc/hosts file (again root/admin needed) and tell it what mysite.local means. Crack open the file and add this line:
127.0.0.1 mysite.local
Save the file and refresh your browser. Bingo, its working (asuming the directory your pointing at exists of course).
If your like me and your containing folder is called the same thing as the server name and you have lots and lots of sites you can save yourself some effort and make use of Apache's VirtualDocumentRoot (bearing in mind you will have to ensure mod_vhost_alias is enabled) and set your config file to have something like this:
<VirtualHost *:80>
VirtualDocumentRoot /Users/username/Sites/%0/docroot
ServerName %0.local
<Directory "/Users/username/Sites/%0/docroot">
AllowOverride All
Options All
</Directory>
</VirtualHost>