PHP and Apache environment variables
Posted
by Simon
on Stack Overflow
See other posts from Stack Overflow
or by Simon
Published on 2010-05-31T02:46:36Z
Indexed on
2010/05/31
2:52 UTC
Read the original article
Hit count: 249
Hello, I want to pass an environment variable in linux to apache on start up.
export MYVAR=5 --I define my environment variable on the command line
PassEnv MYVAR --set apache to import the variable in apache config file
apachectl restart --when I restart apache I don't get an error message. However I have noticed that if I do not create the environment variable in my first step, I get a warning message, so must be working here
echo $_SERVER['MYVAR'] --i try to access the environment variable within PHP but it is not defined
I've observed that if I try to PassEnv an environment variable that already exits (one that I havn't created myself) it works fine. The SetEnv directive also works fine.
I'd really like to pass an environment variable to apache on the fly without writing it in a file. Help much appreciated.
I'm using CentOS, PHP5 and Apache2.
Thanks.
© Stack Overflow or respective owner