Bugzilla – Bug 132769
apache startup script does not reset $HOME
Last modified: 2006-12-20 15:02:54 UTC
Hi, I was recently trying to install a web application that needs a proper $HOME variable set. Unfortunately the startup scripts leave HOME as is, thus pointing to /root which is of course not accesible by the webservers user which is running apps. As a workardound one can hardcode an export HOME= to a proper directory, but the best solution would be to get the information out of /etc/passwd and set it in the startup scripts so apache will run with a usable HOME
You should read http://httpd.apache.org/docs/2.0/env.html and use SetEnv.
From the docs: SetEnv Sets an environment variable, which is then passed on to CGI scripts and SSI pages. Put php is seldom run as cgi, in fact most php software does not work when run as cgi. And when a php script starts some program, these environment settings wont apply, thus using e.g. $HOME from the apache server. This happens e.g. on svn browsing software which runs svn command. The variable with SetEnv makes it to the _SERVER array, but the program started e.g. by system() sees whats in the _ENV array.
just set the proper values in the init script. setting a proper home doesnt harm. not only for php stuff but for other cgi based stuff too.
Okay, mod_php. You can work around by setting HOME (or other environment variables) in /etc/sysconfig/apache2. For 10.1, we will set HOME to /var/lib/apache2. In addition, we will clean the environment a bit (which might make overriding envvars impossible, depending on how we do it...).
downgrading severity
PHP doesn't set $_ENV by default. you need to configure variables_order = "EGPCS" to get $_ENV populated or use apache_setenv to set it. This is the expected behaviuor.
I have set HOME in rcapache2 now, defaulting to /var/lib/apache2. Submitted to the buildservice, will turn up in 10.3 later.