<p>I just want my apache to register some of my predefined environment so that i can retrieve it using getenv function in php. How can i do this? I tried adding /etc/profile.d/foo.sh with export FOO=/bar/baz using root and restarted apache.</p>

Environment variables are inherited by processes in Unix. The files in /etc/profile.d are only executed (in the current shell, not in a subshell) when you log in. Just changing the value there and then restarting a process will not update the environment.
Possible Fixes:
log out/log in, then start apache
source the file:
```
# . /etc/profile.d/foo.sh
```
, then restart apache
source the file in the apache init script
You also need to make sure that
```
/etc/profile.d/
```
is sourced when Apache is started by
```
init
```
rather than yourself.
The best fix might also depend on the distribution you are using, because they use different schemes for configuration.