How to set PHP environment variables on Ubuntu
6,541
The canonical place to set environment variables for apache in ubuntu is /etc/apache2/envvars
. Note that apache would run as the www-data user, not the nobody user. www-data wouldn't have dotfiles in its home anyway.
Additionally, to make the variable available to php, I believe you will need to use PassEnv in the apache configuration
Related videos on Youtube
Comments
-
I. Cantrell over 1 year
I'm sure this is easy if you know how, but I don't.
I've got an ubuntu 10.04 server running PHP5 under apache, all defaults and stuff. The PHP needs some environment variables set. How do I do it?
Do I put them in the apache site config? Do I set them for the
nobody
user? (Who doesn't have a .profile)Thanks!
-
I. Cantrell over 12 yearsLooks like it should be right, but <? echo $_ENV['VAR_SET_IN_ENVVARS'] ?> isn't working. :(
-
stew over 12 yearsyou php script is running via mod_php? or as a cgi?
-
I. Cantrell over 12 yearsit's running through mod_php... i'm pretty sure. it's not in a cgi-bin dir, and a2enmod php was required.
-
I. Cantrell over 12 years@zoredache yes. :)
-
Vaibhav Singhal almost 4 yearsYou can also check this... stackoverflow.com/questions/29079237/…