Baltimore Squirrels

here squirrely, squirrely

Apache setup for local hacking

I do most of my local web development under my userdir (/~tvon), but I don’t like dealing with relative URLs (and some webapps prefer to think they live in your document root). So, I fake it.

Edit /etc/hosts to give localhost some extra aliases:

127.0.0.1       localhost local1 local2 local3 local4 local5

Then tweak apache config to add a few VirtualHosts (in this case in my home dir /Users/tvon):

<virtualhost *>
    ServerName local1
    DocumentRoot /Users/tvon/Sites/local1
</virtualhost>
<virtualhost *>
    ServerName local2
    DocumentRoot /Users/tvon/Sites/local2
</virtualhost>
<virtualhost *>
    ServerName local3
    DocumentRoot /Users/tvon/Sites/local3
</virtualhost>
<virtualhost *>
    ServerName local4
    DocumentRoot /Users/tvon/Sites/local4
</virtualhost>

Now when I want to work on a site, say example.com (assuming it lives in the example.com directory under /Users/tvon/Sites) I symlink it to an available local alias, e.g. ln -s example.com local1 and I can access it as a root site at http://local1/.

Not very fancy, but it makes my life a little easier.

Written by Tom

January 10th, 2008 at 8:13 pm