How can you set the PATH environment variable for Apache2?
I've tried setting it in /usr/sbin/envvars and in httpd.conf with SetEnv PATH (and passing it along to SSI with PassEnv), but it just doesn't get carried along.
|
|
|||||||
|
|
As others have said, you do this through use of the an environment variable file. I will provide more details in this answer, and show proof that it works. This environment variable file must be source from
If the above does not work, something unusual may be happening happening. Perhaps your script is ignoring or overwriting the PATH. |
||||
|
|
|
On my system it's |
|||||
|
|
Make sure you've loaded mod_env. The correct syntax is (example):
This worked for me. |
|||
|
|
|
On my Apache2 system I found that a lot of visitors only wanted to pillage my carefully-compiled collection of Smileys/emoticons (seriously!), so I decided to use a randomly-generated symlink to the directory path that would be picked up as an Apache2 variable, and it was practically impossible to share links. So, every 30 minutes, cron ran a perl script that would rewrite the .htaccess file and include a SetEnv as you can see below:
Then, at the top of my PHP pages I'd read the variable like so, and later in the page there'd be that variable used to build a path to the apprpropriate smiley:
Works for me, and hope it helps you! |
|||
|
|
|
You can set it in
Create a Perl script to list all the environment variables:
Place it into
|
|||
|
|