I add a variable in whole linux varibale in /etc/profile
export MYNAME="My Value"
how can i access this value in php source code during run via apache web server?
in $_SERVER this value doesn’t exist.
just this keys appear on $_ENV:
_ENV["APACHE_RUN_DIR"] /var/run/apache2
_ENV["APACHE_PID_FILE"] /var/run/apache2.pid
_ENV["PATH"] /usr/local/bin:/usr/bin:/bin
_ENV["APACHE_LOCK_DIR"] /var/lock/apache2
_ENV["LANG"] C
_ENV["APACHE_RUN_USER"] www-data
_ENV["APACHE_RUN_GROUP"] www-data
_ENV["APACHE_LOG_DIR"] /var/log/apache2
_ENV["PWD"] /
Trying to set an environment variable for a daemon process is trickier than it sounds. Only interactive login bash shells source
/etc/profile, which probably doesn’t match the criteria of your web server process. See this page for more information.However, you can set environment variables in Apache and PHP.
In Apache configuration file:
Restart, the server. Then you should be able to fetch this variable using
$_ENVin PHP.