$PATH environment variable for apache2 on mac

Solution 1:

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

More in the docs.

Solution 2:

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.

  • Check out the older discussion :
    • How do I add paths to the Apache PATH variable?
    • Setting environment variables in OS X?

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

  • getenv : http://php.net/manual/en/function.getenv.php
  • putenv : http://www.php.net/manual/en/function.putenv.php

    $path = getenv('PATH'); putenv( "PATH=$path:/new_path_that_you_want_to_add" );