in reply to apache::dbi how to switch between development or production database?

Your PerlSetVar idea is good. You can set a key there that you use to pull the values from a hash in your startup.pl or a similar config file. You can also do something where you pass a value to the httpd and use that to switch between sets of PerlSetVars in httpd.conf.

On command-line:

> httpd -DPROD
In httpd.conf:
<IfDefine PROD> PerlSetVar DATABASE_NAME foo PerlSetVar DATABASE_USER bar PerlSetVar DATABASE_PASS baz </IfDefine>

You can do fancier stuff too. In one place that I worked, we used a small script with Template Toolkit to re-generate httpd.conf for different environments based on a small file of values keyed on different environments. It was nice because we had the ability to do inheritance, where we would define defaults and override them for development or other special cases.

Replies are listed 'Best First'.
Re: Re: apache::dbi how to switch between development or production database?
by ignatz (Vicar) on Dec 18, 2001 at 01:18 UTC
    Why does this set my spidey senses to tingling even though it is totally responsive to the question? Personaly, httpd.conf is one file that I do not want in any state of flux, especially if there is more than one person working on a site.
      I told you one way to do it without modifying files (httpd -DSOMETHING). You could also put all of this in a perl config file if you like that better, or use virtual hosts so that one goes to development and one to production depending on the hostname or port you use.