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.

In my phpinfo(), in the section Apache Environment, i want change the value of the variable PATH. This is possible ?

EDIT 1:

I try SetEnv PATH /mypath in httpd.conf on a centos server, restart service and verify the change i see again a phpinfo(), and not change.

EDIT 2:

I edit the /etc/profile and add the PATH variable for all linux users,( but i cant restart the entire server for apply this change).

share|improve this question

migrated from stackoverflow.com Sep 13 '12 at 7:13

This question came from our site for professional and enthusiast programmers.

    
Did you restart Apache after making the change? How are you testing whether or not it works? Is it appropriate to just edit the PATH variable in the .profile file of the user that runs Apache? –  drew010 Sep 11 '12 at 23:21
    
edit, i restart the apache service and see the phpinfo() no has changes. –  Andrés Ricardo Torres Martínez Sep 11 '12 at 23:24
    
What output does var_dump($_ENV['PATH'], $_SERVER['PATH'], getenv('PATH'); show? –  drew010 Sep 11 '12 at 23:27
    
the answer of jpic resolve my issue –  Andrés Ricardo Torres Martínez Sep 11 '12 at 23:39
add comment

1 Answer

up vote 1 down vote accepted

You can use putenv(), example adding "/foo":

php > putenv('PATH=' . getenv('PATH')); print_r(getenv('PATH'));
/home/jpic/env/bin:/home/jpic/local/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin
php > putenv('PATH=' . getenv('PATH') . ':' . '/foo'); print_r(getenv('PATH'));
/home/jpic/env/bin:/home/jpic/local/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/foo
share|improve this answer
add comment

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.