0

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.

2 Answers 2

3

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

3
  • 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, 2013 at 6:14
  • you have to restart your shell (relogin) or just simply execute source ~/.bashrc or the equivalent . ~/.bashrc
    – ardiyu07
    May 18, 2013 at 6:17
  • @Justin: Are you running the PHP code from the logged-in shell? May 18, 2013 at 6:20
0

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .