in reply to Setting the @INC variable for Apache running on Windows
You can also set environment variables for these programs, by using the SetEnv directive. Thus, these environment variables needn't even exist outside of Apache.
Both are controled by the mod_env module. It is loaded by default, so you don't need to do anything to enable is — at least, if "ClearModuleList" is not commented out in the configuration file.
You can set these directives in the main Apache configuration file, "httpd.conf", globally for the whole server; on a per directory basis by wrapping it in <Directory> tags; or per virtual host in a similar way. In addition, you can also set them in a ".htaccess" file, provided it is allowed by the "AllowOverride" directive in "httpd.conf", and as you can see from the mod_env docs, it's "AllowOverride FileInfo" (or "AllowOverride All") that's in charge.
A practical example: I added this to my "httpd.conf" file:
I made sure the directory exists and contains a test CGI script "env.cgi", and a ".htaccess" file in which I put:Alias /servertest "c:/server test" <Directory "c:/server test"> Options ExecCGI AllowOverride None AllowOverride FileInfo PassEnv PROMPT SetEnv PERL5LIB "C:/Apache/htdocs/mokslas/lib" Allow from all </Directory>
Then when I run a CGI script, via the URL <http://localhost/servertest/env.cgi>, I get the following environment variables, among others:SetEnv ENV "Hello, World!"
Note: Putting the directive in ".htaccess" allows you to change the value without restarting Apache. But for such a long-term environment variable like PERL5LIB, I'd rather put it in "httpd.conf".
|
|---|