Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I set an environmental variable for user on CentOS by simply:

1.) Logging in with the user

2.) Going to their home directory cd ~ and creating a file .profile

3.) Putting the following in the .profile file:

export APP="dev"

However, when I:

echo $APP

It is blank. I have tried closing my SSH session and retying, still the same problem.

share|improve this question
up vote 3 down vote accepted

~/.profile is only read for login shells. Either use ~/.bashrc for all bash shells, or ~/.ssh/rc for SSH connections only.

share|improve this answer
Even putting it in my ~/.bashrc I can't get the value from PHP using getenv(), always comes back false. Any ideas? – Justin May 18 '13 at 6:14
you have to restart your shell (relogin) or just simply execute source ~/.bashrc or the equivalent . ~/.bashrc – ardiyu07 May 18 '13 at 6:17
@Justin: Are you running the PHP code from the logged-in shell? – Ignacio Vazquez-Abrams May 18 '13 at 6:20

you can place in /etc/profile.d directory

in you can have the following line

export APP="dev"

it is working

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.