StupidRalph
12-24-2008, 12:23 PM
I was just wondering how everyone else handles their server when creating a new web site (locally).
I've just been creating a new Virtual hosts and modifying my HOSTS file with every new site. Surely there must be a more efficient way to do this.
CFMaBiSmAd
12-24-2008, 12:49 PM
If you were managing a live server, you would be using a Hosting Control Panel and the HOSTS file information would be adding entries to an actual name server instead. You might try to find out if any of the opensource/free hosting control panels support using a HOSTS file, otherwise, you probably need to write a script to do this yourself.
schleppel
12-24-2008, 05:45 PM
I use a PAC file (http://en.wikipedia.org/wiki/Proxy_auto-config)
function FindProxyForURL(url, host)
{
if(isPlainHostName(host)
|| dnsDomainIs(host, '.internal'))
{
return 'PROXY 127.0.0.1:80; DIRECT';
}
else
{
return 'DIRECT';
}
}
Any host name without a dot (PlainHostName) or any .internal domain name will be sent to 127.0.0.1:80.
And mod_vhost_alias (http://httpd.apache.org/docs/2.2/mod/mod_vhost_alias.html)
# Catch all.
# http://example/ to /path/example/
# http://example.com/ to /path/example.com/
<VirtualHost *:80>
ServerName _default_
DocumentRoot /path/
VirtualDocumentRoot /path/%0
</VirtualHost>
# For .internal
# http://example.internal to /different/example/
<VirtualHost *:80>
ServerName a.internal
ServerAlias *.internal
DocumentRoot /different/
VirtualDocumentRoot /different/%-2+
</VirtualHost>
# A "normal" document root for example.org.
<VirtualHost *:80>
ServerName example.org
ServerAlias *.example.org
DocumentRoot /another/example.org
</VirtualHost>
A problem with VirtualDocumentRoots is that it does not change the DOCUMENT_ROOT variable.
StupidRalph
12-30-2008, 12:39 PM
Been away on holiday....
But I chose to use dynamic virtual hosts. But I plan on looking at the above suggestions thanks.
http://httpd.apache.org/docs/2.0/vhosts/mass.html
schleppel
12-30-2008, 07:53 PM
But I chose to use dynamic virtual hosts.
That's the same as what i was suggesting (the second part).
The PAC file part is a replacement for editing the HOSTS file each time to add a new "domain".
StupidRalph
01-05-2009, 12:53 PM
Sorry, I did notice that after I posted. Thanks for your help for pointing me in the right direction with the PAC file.