All major OSes have a "hosts" file. Unix users will find it in /etc, Windows users in %SYSTEMROOT%\system32\drivers\etc. You can enter aliases into it, so that you can call your local computer by any number of names. For example, you could say:
127.0.0.1 www.client-a.lo
127.0.0.1 www.client-b.lo
127.0.0.1 www.client-c.lo
Then in your Apache configuration, you can create VirtualHost entries for each of these. For example, my local Apache installation looks like the following:
NameVirtualHost www.client-a.lo
NameVirtualHost www.client-b.lo
NameVirtualHost www.client-c.lo
<VirtualHost www.client-a.lo>
DocumentRoot /Users/me/Sites/client-a.lo
ServerName www.client-a.lo
</VirtualHost>
<VirtualHost www.client-b.lo>
DocumentRoot /Users/me/Sites/client-b.lo
ServerName www.client-b.lo
</VirtualHost>
<VirtualHost www.client-c.lo>
DocumentRoot /Users/me/Sites/client-c.lo
ServerName www.client-c.lo
</VirtualHost>
This has several benefits to it, namely:
- That cookies will set properly where they often won't if you're just using "http://localhost/".
- That you get easier names to remember.
- That you can have multiple web sites installed on your desktop/development machine at once, without having to keep them all in subfolders of one document root.
Revised on November 17, 2005 7:30 AM by admin
Back in time (4 more) | Linked from: Trouble Shooting, Unable To Login