My system is Ubuntu and I have set my environment variables in /etc/environment.
If I\'m running PHP script using
Recently i wrote a library to get values from environment variables and parse to the PHP data types. This library can be used to parse environment variables to PHP data types (like the casting to integer, float, null, boolean), parse the complex data structures like a JSON string and more with the contribution of the commnunity.
The library is available here: https://github.com/jpcercal/environment
Put your environment variables into "/etc/environment" and "/etc/apache2/envvars", after restart your Apache Server and load your environment variables to operational system:
# source /etc/environment
# source /etc/apache2/envvars
And to get the values from environment variable (independently of the environment CLI, Apache, Nginx, PHP Built-in Server and more) to do it:
Enjoy it.