$PATH environment variable for apache2 on mac $PATH environment variable for apache2 on mac php php

$PATH environment variable for apache2 on mac


You can set the PATH environment variable in /System/Library/LaunchDaemons/org.apache.httpd.plist.

More in the docs.


Did you update the PATH environment variable of user '_www'? Apache will read environment variables from the user runs itself. Or, it looks like you didn't restart apache after updating PATH environment variable.

And if you want to modify environment variable in PHP, getenv() and putenv() can be a better choice.


Important note for El Capitan (Apologies for the new answer - I don't have enough Rep to comment)

On OSX 10.11, the /System/Library folder is protected, so the files can't be edited.

You need to:

  • Reboot into Recovery Mode (hold CMD + r after the startup sound)
  • Once in recovery mode, go to Utilities > Terminal
  • Run:csrutil disable
  • Reboot back into OSX - you should now be able to change the files
  • Once done, go back to recovery mode and runcsrutil enable

Hope that helps