Re-initialize the entire system environment variable in Linux

I just want my apache to register some predefined environment so that I can get it using getenv function in php. How can i do this? I tried adding /etc/profile.d/foo.sh with export FOO = / bar / baz using root and restarted apache.

+5
source share
4 answers

Environment variables are inherited by processes on Unix. Files in the /etc/profile.d file are executed only (in the current shell, and not in the subshell) at the login. Just changing the value and then restarting the process will not update the environment.

Possible fixes:

  • log out / log in and then run apache
  • : # . /etc/profile.d/foo.sh, apache
  • apache init script

, /etc/profile.d/ , Apache init, .

, .

+6

SetEnv (/etc/httpd/conf.d/*.conf,.htaccess...). , /etc/sysconfig/httpd ( RPM) (: ).

. , , , , , Apache. , . . Apache , sourcing/etc/profile.d/yourprofile.sh /etc/sysconfig/httpd

0

Apache .

, - , - , , PHP -.

. Apache mod_env:

0

If you only need env vars for Apache, then editing /etc/apache2/envvarsand restarting Apache worked for me . I added these settings:

export LANG='en_US.UTF-8'
export LC_ALL='en_US.UTF-8'
0
source

All Articles