[Solved] Setting Environment variables for use in PHP


I can’t figure out how to set an environment variable that I can then access from PHP using getenv()

I want to set an API key in the environment so that it’s not hard coded in the app, and access it like this:

  $api_key = getenv("API_KEY");

So far everything I’ve tried has failed to work. :frowning:

OK, I figured it out:

Just set them in the vHost Conf file:

extprocessor blah1234 {
  env API_KEY=secretkey

but the missing link is you must restart PHP otherwise that key won’t be visible with getenv():

killall -9 lsphp