skip to Main Content

Please could I have step by step instructions to set the authentication.json file as environment variable instead of having the json file in my project location
For example:

$jsonAuth = getenv('JSON_AUTH');

Running CentOS Linux 7.9.2009 with Apache

2

Answers


  1. Ideally, you want to encode the json to base 64. Its easier as base64 gets rid of the printable characters that need to be escaped. After that, you can do the following in PHP.:

    $jsonAuth = json_decode(base64_decode(getenv('JSON_AUTH')), true);
    
    Login or Signup to reply.
    1. Make sure you have mod_env installed (it usually is, but double
      check this).
    2. Find the <VirtualHost> for your application, and add SetEnv JSON_AUTH your_token_here, and as many other auth variables you
      need to set.
    3. Reload Apache (apachectl -k graceful or via init.d).
    4. Read out the variables using $jsonAuth = apache_getenv('JSON_AUTH');.
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search