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:
/etc/paths
and /etc/paths.d
export PATH=$PATH:/opt/local/bin
to MAMP/Library/bin/_envvars
/System/Library/LaunchDaemons/org.apache.httpd.plist
after disabling SIP to make it possible. 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.