title: How to set global environment variables for PHP
body: <p>I have read the question/answers <a href="https://stackoverflow.com/questions/13568191/how-to-get-system-environment-variables-into-php-while-running-cli-apache2hand#_=_">here</a> but I don't understand how to set variables in <strong>/etc/environment</strong>. If I edit the file, do I need to restart my machine or simply log out my current user (or log in a new one?). </p>
  
  <p>I want to set a global variable to denote that websites on my machine are in 'development' or 'testing' mode. I don't want to have to set this for every project (whether it uses PHP, Java/Tomcat, NodeJS, etc). I'm aware that (for Apache) I can set the environment variable in the following ways:</p>
  
  <ol>
  <li>directly from php with <code>putenv()</code> (this seems useless since I want to avoid logic that tries to figure out what server the files are on)</li>
  <li>using .htaccess <code>SetEnv ENVIRONMENT 'local'</code> (this would require me to duplicate this file/code for every server, not ideal)</li>
  <li>using a Virtual Host directive <code>SetEnv ENVIRONMENT 'local'</code> (if I'm using a virtual host, which in nearly all cases I am, but again requires me to copy/paste code over and over again) </li>
  <li>in httpd-conf <code>SetEnv ENVIRONMENT 'local'</code> (this will only apply to apache, and I would like it to apply to NodeJS servers as well)</li>
  </ol>
  
  <p>I'm not saying I can't do #4 (and apply #3 selectively to NodeJS servers). But I'm thinking that this is a good reason to use /etc/environment. As I said above, I have edited the file (after first creating it) and tried the following combinations, none of which seemed to work:</p>
  
  <pre><code>ENVIRONMENT='local'
  ENVIRONMENT=local
  export ENVIRONMENT='local'
  export ENVIRONMENT=local
  </code></pre>
  
  <p>I say that none of them worked because I did not find the variable in output from:</p>
  
  <pre><code>print_r($_SERVER);
  print_r($_ENV);
  echo(getenv('ENVIRONMENT'));
  </code></pre>