简体   繁体   中英

How to set Mod_Env in Apache24 Windows

Maybe a silly question, but how do I pass environment variables in apache. I have enabled the LoadModule env_module modules/mod_env.so statement in apache's httpd.conf file and I know from documentation that I should use the statement PassEnv env-variable [env-variable] . But where exactly do I need to add this line (in which file and on what position)?

Ie I want my system variable

PassEnv PYTHONPATH C:\Python\DLLs;C:\Python\lib;C:\Python;C:\Python\lib\site-packages

to be propagated to my web-server. Where do I put it?

Sorry, I'm an absolute beginner with apache and can't seem to find any step-by-step instructions for this problem.

You can set the environment variable in a .htaccess file, which needs to be placed in the root of your website:

PassEnv PYTHONPATH C:/Python/DLLs;C:/Python/lib;C:/Python;C:/Python/lib/site-packages

Notice that I use forwards slashes in the path so that apache won't interpret them as escape characters.

To enable the use of .htaccess files you also need to make sure so the webroot (in other words the DocumentRoot ) has AllowOverride All in the configuration:

<Directory "C:/WEBROOT">
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM