Adding Virtual Hosts without Restarting Apache

We had a requirement of setting up an Apache 2.2 / ColdFusion 8 web server that could have virtual hosts added throughout the day without any disruption to running pages.  Initially it looked like an Apache graceful restart would be a fine solution for this.  However, what we ended up finding is that any running ColdFusion pages actually received a “JRun Connector Protocol Error” message.

We confirmed that this issue existed by creating a ColdFusion page that outputted a message every second (using CFFLUSH to make it outputted to the screen).  While this was running we then ran “kill -SIGUSR1 `cat /var/run/httpd.pid`” and received the following message:

———-

Server Error
The server encountered an internal error and was unable to complete your request.
JRun Connector Protocol Error.

———-

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”.