[ale] setting an env variable that apache will see when calling a cgi script
Geoffrey
lists at serioustechnology.com
Tue Jul 21 07:46:21 EDT 2009
Brandon Checketts wrote:
> Geoffrey wrote:
>> I'm trying to figure out how to set an env. variable that will be
>> available to a perl cgi script. I've tried putting it in the
>> /etc/sysconfig/httpd file as well as in the /etc/init.d/httpd script,
>> but it does not find it's way to the process that executes the cgi.
>>
>> Anyone know how to do this? For example:
>>
>> print $ENV{'FOO'};
>>
>
> You can set them inside your Apache config with the mod_env Apache module, which
> should be included with most basic Apache installations.
>
> <VirtualHost>
> ServerName your.domain.com
> ... your other configuration here...
> SetEnv somevar "some value"
> SetEnv
> </VirtualHost>
>
> Documentation for the module is at
> http://httpd.apache.org/docs/2.2/mod/mod_env.html is pretty straightforward.
Thanks, that gets me almost what I want. Basically, we have a existing
env variable that we want accessible to the cgi scripts. But you put me
on the right track as:
PassEnv variable
Does exactly what I need. Thanks!
>
>
> The mod_setenvif is a bit more flexible and allows you to use conditionals to
> set environment variables. Documentation at
> http://httpd.apache.org/docs/2.2/mod/mod_setenvif.html
>
>
> Example:
>
> SetEnvIf Host !"^www\.hostname\.com$" wronghost=1
>
>
> That will set the environment variable 'wronghost' to 1 if the HTTP_HOST header
> is not 'www.hostname.com'. Your Perl script can then respond accordingly
> (perhaps redirecting to the correct domain name in this case)
>
>
>
> Thanks,
> Brandon Checketts
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
>
--
Until later, Geoffrey
Those who would give up essential Liberty, to purchase a little
temporary Safety, deserve neither Liberty nor Safety.
- Benjamin Franklin
More information about the Ale
mailing list