简体   繁体   English

更新到El Capitan后在MAMP中设置PHP exec路径时出现问题

[英]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. 对于这么简单的事情,我发现在运行El Capitan的Mac上,很难在MAMP下设置PHP exec()命令使用的路径非常困难。

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. 我需要使用环境变量而不是(例如)PHP的putenv()或硬编码的“ PATH = foo &&”的解决方案,因为此代码将在不同的服务器上使用,每个服务器可能使用不同的路径。 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. 我在优胜美地上运行得很好(尽管,老实说,我不记得什么最终成功了),但是当我升级到El Capitan时,这条路被重置了。

I've tried the following, and have restarted the computer after each just to be entirely sure that Apache's path was being reset: 我尝试了以下操作,并在每次启动后都重新启动了计算机,以完全确保已重置Apache的路径:

  • Added to path in /etc/paths and /etc/paths.d 添加到/etc/paths/etc/paths.d /etc/paths
  • Added export PATH=$PATH:/opt/local/bin to MAMP/Library/bin/_envvars MAMP/Library/bin/_envvars添加了export PATH=$PATH:/opt/local/bin
  • Even set path in /System/Library/LaunchDaemons/org.apache.httpd.plist after disabling SIP to make it possible. 甚至在禁用SIP后也可以在/System/Library/LaunchDaemons/org.apache.httpd.plist设置路径。
  • 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. 编辑添加 :还尝试了默认路径中某个位置的符号链接,但例如LaTeX确实需要保留在该路径中。

After each of these, the path (as indicated by a "exec('echo $PATH', $output);" command in the PHP) remains the same: 在上述每一个之后,路径(如PHP中的“ exec('echo $ PATH',$ output);”命令所示)保持不变:

\/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: 在Mavericks上,它的工作方式如下:
- Stop MAMP -停止MAMP
- Rename the file /Applications/MAMP/Library/bin/envvars_ to /Applications/MAMP/Library/bin/envvars (without underscore). -将文件/Applications/MAMP/Library/bin/envvars_重命名为/Applications/MAMP/Library/bin/envvars (不带下划线)。
- 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 -启动MAMP并查看phpinfo()输出

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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