Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:


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


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

share|improve this question
up vote 2 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.

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

Your Answer


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.