For setting the operating system environment variables to be used by apache, we will export these variables to the apache server when it starts. The procedure is as follows :
0. Switch to root.
1. Open /etc/init.d/httpd in vim
2. You will find following lines
# Source function library.
Open /etc/rc.d/init.d/functions in vim
3. You will find following lines
# Set up a default search path.
Now append whatever environment variables you want to set and accessed by apache.
You could have added these lines anywhere in the file.4. Save the file and restart the apache server.
Hope it helps. I will add the fix for Ubuntu soon.