title: PHP and Apache environment variables
body: <p>I want to pass an environment variable in linux to apache on start up. </p>
  
  <p>export MYVAR=5 
  --I define my environment variable on the command line</p>
  
  <p>PassEnv MYVAR 
  --set apache to import the variable in apache config file</p>
  
  <p>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</p>
  
  <p>echo $_SERVER['MYVAR'] 
  --i try to access the environment variable within PHP but it is not defined</p>
  
  <p>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. </p>
  
  <p>I'd really like to pass an environment variable to apache on the fly without writing it in a file. Help much appreciated. </p>
  
  <p>I'm using CentOS, PHP5 and Apache2. </p>
  
  <p>Thanks. </p>
  
  <p><strong><em>update</em></strong>
  it seems the environment variable gets passed if i invoke the apache startup directly with httpd and not use apachectl which is a shell script. I would have thought that the "export" would have exported the variable to the shell script no? I am not a linux guru so excuse my lack of knowledge. </p>