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

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!

  • I have automated scripts that handle issuing graceful restarts (or reloads in the case of adding SSL sites). If you look at something like CPANEL, which lots of hosting companies use, you will see it indeed does a graceful when adding/deleting sites.
    – Doon
    Sep 13 '11 at 18:52

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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.