How can I configure VirtualHost without restarting Apache web server?

I have mentioned here apache web server because i am using that one.


I just had a look at this page but not sure how relevant its to yours.

Dynamically Configured Mass Virtual Hosting

The basic idea is to replace all of the static configurations with a mechanism that works them out dynamically. This has a number of advantages:

  1. Your configuration file is smaller, so Apache starts more quickly and uses less memory.
  2. Adding virtual hosts is simply a matter of creating the appropriate directories in the filesystem and entries in the DNS - you don't need to reconfigure or restart Apache.

UPDATE

Adding Virtual Hosts without Restarting Apache

It turned out that the solution was to use VirtualDocumentRoot instead of just the plain old DocumentRoot setting for a single virtual host. This allowed specifying the $0 variable as part of the value. So we ended up being able to have “VirtualDocumentRoot /somedir/$1″.


Make any changes to your VirtualHosts, then do

apache2ctl configtest

To make sure there aren't any outstanding syntax errors, and run this:

apache2ctl graceful

or

/etc/init.d/apache2 graceful

The USR1 or graceful signal causes the parent process to advise the children to exit after their current request (or to exit immediately if they're not serving anything). The parent re-reads its configuration files and re-opens its log files. As each child dies off the parent replaces it with a child from the new generation of the configuration, which begins serving new requests immediately.

Basically any existing connections stay intact, so it's not the same as a full restart - this is how I usually do this on production servers with dozens of sites.