3

Where can I find the envvars configuration file (if there are any) in CentOS?

I know in Ubuntu, Apache2, I can find it from /etc/apache2/envvars

I've tried the command,

export EXAMPLE=value command. Does it require server restart to get it affected?

Please advise, thanks in advance :)

3 Answers 3

4

Global Environment variable file is :- /etc/profile

Local Environment Variable ( User Specific ) file is :- ~/.bash_profile

14
  • There are some existing environmental variables, which I get using PHP getenv() function. I would like to know where this is saved in. Commented Jan 19, 2016 at 11:55
  • you can use set command and this will list all the env variables in your current session. Commented Jan 19, 2016 at 11:59
  • I'm able to add this through WHM, but need to know where does it get saved. Commented Jan 19, 2016 at 12:06
  • through getenv() function you get the value of environment variable that are already stored. Commented Jan 19, 2016 at 12:15
  • Agree, would like to know where does these environmental variables get stored? Like in Apache2 /etc/apache2/envvars. Commented Jan 19, 2016 at 12:23
1

Rehdat Equiv to /etc/apache2/envvars

The Redhat and Centos equiv to /etc/apache2/envvars is /etc/sysconfig/httpd

The other answers are also correct if you are ok with the variables being truly global. Using /etc/sysconfig/httpd will keep the variables confined to httpd.

As Siddharth sharma pointed out, you can also set the environment variable in the apache config.

e.g.

SetEnv TMPDIR /var/www/.cgitmp 
5
  • The file /etc/sysconfig/httpd doesn't exist!! Commented Jan 20, 2016 at 5:21
  • How did you install apache? If you used yum install httpd then you most certainly would have that file. Commented Jan 20, 2016 at 6:38
  • I'm not sure. I'm new to Linux, it was done by someone else and I'm figuring it out. Thanks :) Commented Jan 20, 2016 at 6:48
  • If someone removed the file by mistake, you can put it back. By default, it just contains LANG=C and a commented out #OPTIONS= Commented Jan 20, 2016 at 6:50
  • As @Siddharth sharma said, If you don't find your variables in these than it might be possible they exists at runtime. The kernel stores the list of environment variables and their values for each process. I was able to find the environ files under different process. How can I find out whether the apache runs on httpd or litespeed? I could see both processes running. Confused. Commented Jan 20, 2016 at 7:43
0

Just run set and you will see all env variables of your session.
export acts immideately, you don't need any extra actions.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.