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.

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

share|improve this question

1 Answer 1

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

 
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.