[Solved] Setting Environment variables for use in PHP

Hi,

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

This topic was automatically closed 3 hours after the last reply. New replies are no longer allowed.