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
vim /etc/init.d/httpd
2. You will find following lines
# Source function library.
. /etc/rc.d/init.d/functions
Open /etc/rc.d/init.d/functions in vim
vim /etc/rc.d/init.d/functions
3. You will find following lines
# Set up a default search path.
PATH="/sbin:/usr/sbin:/bin:/usr/bin"
export PATH
Now append whatever environment variables you want to set and accessed by apache.
VAR="/path/to/var"
export VAR
For example,
LD_LIBRARY_PATH=/usr/local/lib:/usr/local/cuda/lib
export LD_LIBRARY_PATH
You could have added these lines anywhere in the file.4. Save the file and restart the apache server.
/etc/init.d/httpd restart
Hope it helps. I will add the fix for Ubuntu soon.