简体   繁体   中英

Problems setting PHP exec path in MAMP after update to El Capitan

For something that should be so simple, I'm finding it maddeningly difficult to set the path that PHP exec() commands use under MAMP on a Mac running El Capitan.

I need the solution to use environment variables rather than (for example) PHP's putenv() or a hardcoded "PATH=foo && ", as this code will be used on different servers that each may use a different path. I had it working fine on Yosemite (though, to be honest, I can't remember what finally worked), but when I upgraded to El Capitan the path was reset.

I've tried the following, and have restarted the computer after each just to be entirely sure that Apache's path was being reset:

  • Added to path in /etc/paths and /etc/paths.d
  • Added export PATH=$PATH:/opt/local/bin to MAMP/Library/bin/_envvars
  • Even set path in /System/Library/LaunchDaemons/org.apache.httpd.plist after disabling SIP to make it possible.
  • Edit to add : Also tried a symbolic link to somewhere in the default path, but LaTeX, for example, really needs to live on the path.

After each of these, the path (as indicated by a "exec('echo $PATH', $output);" command in the PHP) remains the same:

\/usr\/bin:\/bin:\/usr\/sbin:\/sbin

I'm at wit's end. If anybody's managed to set the path on a similar setup, I'd love to get input on how it was done.

Thanks!

On Mavericks it worked like this:
- Stop MAMP
- Rename the file /Applications/MAMP/Library/bin/envvars_ to /Applications/MAMP/Library/bin/envvars (without underscore).
- Add these two lines at the end of the renamed file:

PATH="$PATH:/additional/path1:/additional/path2"
export $PATH

- Start MAMP and have a look into phpinfo() Output

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM