Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

2 Answers 2

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 myenv.sh in /etc/profile.d directory

in myenv.sh you can have the following line

export APP="dev"

it is working

share|improve this answer

Your Answer

 
discard

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.