LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Apache webserve SetEnv PATH??? (https://www.linuxquestions.org/questions/linux-server-73/apache-webserve-setenv-path-772802/)

KirkD 12-01-2009 06:52 PM

Apache webserve SetEnv PATH???
 
I'm setting up a web server on my CentOS 5.4.3 (x86_64) system and the Python toolkit that I'm using (RDKit - RDKit.org) expects to have its location specified in the PATH environment variable. This is all good and fine when I use the toolkit on my own as I have

export RDBASE=/opt/RDKit
export PATH=$PATH:$RDBASE

in my .bashrc.

But, since this is a web server, I need to have the PATH set for Apache. I can get all the other necessary environment variables set from httpd.conf, but not PATH.

I also tried to include a new .sh file in /etc/profile.d - rdkit.sh - which contained the specified export PATH statement above, but Apache doesn't recognize it even if I include the PassEnv directive in httpd.conf:

PassEnv PATH

Any ideas???

-Kirk

j-ray 12-02-2009 04:37 AM

I guess you simply have to set the variable system wide in /etc/profile with the mentioned export statements, then
'source /etc/profile'
and restart apache.
'/usr/sbin/apache2ctl restart'

zhjim 12-02-2009 04:45 AM

Try the SetEnv directive of apache.
I always tested the env of apache within php like this

Code:

passthrough('env')
Cheers Zhjim

P.S.
Don't forget to restart apache after config changes

KirkD 12-02-2009 01:38 PM

j-ray:

I tried adding the export line to /etc/profile - no luck. I also notice that if I look at the environment variables in apache with this code running from my web page:

for a in os.environ.keys():
print a, ' = ', os.environ[a], '<BR>'

and comparing that to what I get as my user or root, the PATH variable is different from all of them. In other words, I can see that this approach changed the root PATH variable, but it seems to have no effect with the webserver.


zhjim:

Thanks for the idea, but I've tried that. I have all my other necessary environment variables set using SetEnv within httpd.conf. I also tried PassEnv PATH once I had root's environment variable set correctly - still no luck.

Any other ideas out there??? How do I get to the apache user's account and how it has its environment variables set?

-Kirk

KirkD 12-02-2009 03:56 PM

Work around
 
Well, I can't seem to affect the PATH, but as it turns out I can opt to set PYTHONPATH instead. I also discovered that within the httpd.conf file, I have to explicitly spell out the directories. In other words, this didn't work:

SetEnv RDBASE /opt/RDKit_Q32009_1
SetEnv PYTHONPATH $RDBASE:$RDBASE/bin

but it DID work as this:

SetEnv RDBASE /opt/RDKit_Q32009_1
SetEnv PYTHONPATH /opt/RDKit_Q32009_1:/opt/RDKit_Q32009_1/bin

From pain comes knowledge, eh?

-Kirk

zhjim 12-03-2009 01:51 AM

Quote:

Originally Posted by KirkD (Post 3777611)
From pain comes knowledge, eh?

I always learn by doing things wrong, rights for loosers and eegheads :p


All times are GMT -5. The time now is 12:20 PM.