title: How to get system environment variables into PHP while running CLI & Apache2Handler?
body: <p>My system is <strong>Ubuntu</strong> and I have set my environment variables in <code>/etc/environment</code>.</p>
  
  <p>If I'm running <strong>PHP</strong> script using <strong>CLI</strong> - environment variables from <code>/etc/environment</code> are recognized.</p>
  
  <p>But, if I go to execute <strong>PHP</strong> script thru <code>http://domain/test.php</code> (that is <strong>apache2handler</strong>) exactly the same script prints out NULL, meaning environment variables from <code>/etc/environment</code> are not loaded.</p>
  
  <p>The fix I did was adding variables in <code>/etc/apache2/envvars</code> and that solved the problem.</p>
  
  <p>But that is two different files, which then have to be kept in sync.</p>
  
  <p>How can I make <strong>PHP</strong> / <strong>Apache</strong> load and recognize environment variables from <code>/etc/environment</code> (system)?</p>
  
  <p>EDIT: To clarify things, when I say 'not loaded into PHP' it means variables from <code>/etc/environment</code> are not set in <code>$_SERVER</code>, <code>$_ENV</code>, <code>getenv()</code> and do not exists in <code>$GLOBALS</code>. In other words 'are not loaded into PHP'.</p>