1819984 Members
3825 Online
109607 Solutions
New Discussion юеВ

Re: Apache configuration

 
SOLVED
Go to solution
Claudio Cilloni
Honored Contributor

Apache configuration

Does anybody know why Apache's SetEnv command
doesn't work? I wrote this
in httpd.conf:


SetEnv ORACLE_HOME /home/oracleclient/oracle_home
Order allow,deny
Allow from all
Options +ExecCGI


But no ORACLE_HOME env variable could be found by my cgi scripts. No errors in apache's logs.

thanks
11 REPLIES 11
Vitaly Karasik_1
Honored Contributor

Re: Apache configuration

"Directory and .htaccess context is available in Apache 1.3.7 and later" (from http://httpd.apache.org/docs/mod/mod_env.html#setenv) - which version do you run?

You can put SetEnv in server config or virtual server config

Vitaly.

Claudio Cilloni
Honored Contributor

Re: Apache configuration

I'm running apache-1.3.27-2.
It's funny to see that the SetEnv command works well in another part of httpd.conf:

...

...
Alias /gest/ "/home/web/gest/"

SetEnv PYTHONPATH /home/web/gest/site-packages:/home/web/gest/app-packages:/home/web/gest/applications
SetEnv ORACLE_HOME /home/oracleclient/oracle_home
Order allow,deny
Allow from all
Options +ExecCGI


...


In this aliased directory the env variables are visible by the scripts.
But not in the user web directories.

tx
Claudio
Jerome Henry
Honored Contributor

Re: Apache configuration

Can it be related to your /home/*/public_html then /home/oracleclient/oracle/home, won't you have to define /home/*/oracle/home instead, or is ocalcle_home but only one dir ?
You can lean only on what resists you...
Claudio Cilloni
Honored Contributor

Re: Apache configuration

the string '/home/oracleclient/oracle_home/' is only the value
of the environment variable ORACLE_HOME that my cgi scripts
need to see. It has no interest for apache.

The only difference I see between my two examples is that
the cgi scripts running in the user web directories (first
example) will the started by apache through the command
suexec, which lets apache to change the user that owns the script's process.
Nevertheless this, all the other apache-specific environment
variables are still available to the cgi scripts, but not
the variables I defined.

tx again
Claudio
Steven E. Protter
Exalted Contributor

Re: Apache configuration

Your methodology is interesting, but not how oracle does it in their own modfication of apache, which they ship with their application server(HP-UX).

They set variables in the cgi script itself. If they need to be configured differently on different occaisions, the cgi script reads a data file and sets environment variables accordingly.

If all you are doing is setting ORACLE_HOME, go ahead and hard code it into the script, thats all you're trying to do with the httpd.conf anyway.

SEP

Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Claudio Cilloni
Honored Contributor

Re: Apache configuration

This is surely a good workaround, and it's easy to implement. But it doesn't solve this unwanted behaviour from apache (it could be my fault, of course... I'm looking for someone that knows apache better than me :-)

tx
Claudio
Steven E. Protter
Exalted Contributor

Re: Apache configuration

If the directive is working in other parts of the httpd.conf file, then it should be workable for you.

I would try and move the directive to a different part of the file.

If you have virtual hosting setup to handle more than one IP/website, then move the code there.

Then

service httpd restart

Run a test script and see if the variable is set.

If you are running perl in the cgi script there is a directive for bringing environment variables into a normal variable. It could be geting set, but you might need to pull it in.

$variable=$ENV{'CONTENT_LENGTH'};

$oracle_home=$ENV{'ORACLE_HOME'};

Mabye the variable IS being set, just the script isn't set up to read it in and use it.

This code with a print statement would be a very good test as you play with apache.

Hope this helps.

SEP

Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Jordan Bean
Honored Contributor

Re: Apache configuration

is literally looking for path '/home/*/public_html'. Instead, use regular expressions this way:


...


or


...


Claudio Cilloni
Honored Contributor

Re: Apache configuration

the string '/home/*/public_html' matches any public_html directory
in user homes, not the literal '/home/*/public_html' (I taken
it from a commented example in apache's original httpd.conf file).
the match string is correct because the directive 'Options +ExecCGI'
works. However, the regular expression string doesn't change
a thing. But I think it is a better way to say the same thing :-)

Thanks anyway!
Bill Douglass
Esteemed Contributor
Solution

Re: Apache configuration

Inthe apache documentation at:

http://httpd.apache.org/docs/env.html


When suexec is used to launch CGI scripts, the environment will be cleaned down to a set of safe variables before CGI scripts are launched. The list of safe variables is defined at compile-time in suexec.c.

I suspect the suexec is your problem. You can modify the suexec.c file to allow ORACLE_HOME and re-compile apache, or launch your CGIs without using suexec.
Claudio Cilloni
Honored Contributor

Re: Apache configuration

Thanks a lot, Bill. problem solved!