Using PHP 5.3 as an Apache module with Apache 2, on OS X 10.7.

When I open Terminal and enter echo $PATH I get:

/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/imagemagick/bin

But when I run getevn('PATH') in PHP I get:

/usr/bin:/bin:/usr/sbin:/sbin

Which means most calls to exec() in PHP fail to find the commands/binaries I want. I've tried these two in httpd.conf:

SetEnv PATH /opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/imagemagick/bin

PassEnv PATH

Neither have any effect. How do I get PHP/Apache's PATH variable to mirror my users PATH variable? (Ideally in such a way that if mine ever changes Apache's doesn't need manually changing as well.)

link|improve this question

feedback

1 Answer

up vote 1 down vote accepted

Change the user (directive) to your logged in username. I wouldn't recommend doing that in a productive environment. However to fiddle things out, in a closed test environment you get what you want.

link|improve this answer
Perfect, thanks! This is only on a development machine so that's fine. – Jack Sleight Dec 12 '11 at 12:04
feedback

Your Answer

 
or
required, but never shown

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