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.)
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.