How to set and retrieve environment variables using PHP on EC2 instance

Viewed 1793

I am having an issue with trying to set environment variables in my EC2 instance and then retrieving them with php.

So I have an EC2 instance running a Bitnmai Wordpress site. I ssh's into the server and added the environment variable in /etc/environment

export VARIABLE_NAME=example_value

on the front end of things, my php to retrieve the value is:

<?php $env_var = $_ENV["VARIABLE_NAME"];

But it returns blank

I have also tried

$env_var = array('environment' => getenv("VARIABLE_NAME"));

But that just returns {environment: false}

Any help would be greatly appreciated

2 Answers
Related