My method  is UNIX specific. I have a directory structure with softlinks  --
one for "live" and one for "development". The "live" link points to the
current version (checked out from svn or cvs) of the site. The "development"
points to another directory where developers can change stuff.
Then, as Krist suggested, there are two apache instances running. They use
the identical configuration files, and in a key file you have something like
this:

<ifdefine TEST>
 SetEnv HTTP_TEST 1
 include "conf/httpd-test.conf"
</ifdefine>
<ifdefine !TEST>
 include "conf/httpd-production.conf"
</ifdefine>

Then I start the main server normally, but the development server with
-DTEST.  The production server will use the httpd-production.conf file,
where you can set your DirectoryRoot and ServerRoot paths specific to that
configuration. You can also set environment variables so that PHP and CGI
scripts can test the existence of such a variable to chose between the
production or development database. Above, HTTP_TEST is such an environment
variable only visible during the TEST configuration.

You can also rig it in a way so that just changing the directory links for
LIVE and TEST will do everything you need it to. For that to work, the
scripts should look at the full path of the script being run; if that path
contains LIVE, then the script should use the "live" database; otherwise, it
should use the "development" database. PHP and Perl can do this easily by
looking at the full path they were invoked with. However: some OS's will
translate paths with soft-links into the "real" path, making this method
unusable. If that's the case, the scripts can test for the existence of a
particular file in the current directory, which only exists in the
production site.

Reply via email to