Adding virtual hosts without restarting Apache

apache-2.2hostsnamevirtualhostvirtualhost

I've got Apache 2.28, on Web-Developer Server Suite, PHP 5.38, MySQL latest version, and have got about 5 virtualhosts.

This is my latest virtual host, which was a dynamic one:

UseCanonicalName Off
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.my-goods-distributor.co.uk 
ServerAlias my-goods-distributor.co.uk
DocumentRoot /www/my-goods-distributor.co.uk
ScriptAlias /cgi-bin/ /www/my-goods-distributor.co.uk/bin
</VirtualHost>

I added it to hosts and it took me to localhost's page instead.
Normally after adding virtual hosts I use cmd, and type in httpd -k restart (graceful restart) which does it, but I want to try and automate this process a bit.

I did try what was in the documentation, but I'm new to this.

How should/can I get Apache to add virtualhosts without restarting the server by hand, like webhosting companies do, even though I'm using Windows and a hosts file?
I don't think the major webhost companies turn the servers on and off by hand, and my server, although it's a testing one, is intended to replicate some functions of PHP/MySQL before any sites go live on other webhosts.

Any advice is appreciated, thanks!

Best Answer

Apache's mod_vhost_alias is what I'd imagine many shops use. There are also some ldap or sql-backed vhost modules, but my google-fu is failing me at the moment.

http://httpd.apache.org/docs/2.0/mod/mod_vhost_alias.html

Related Topic