问题实际上是由php-fpm
5.6运行的PHP脚本,该脚本是从MacPorts
安装的。
PHP代码system('echo $PATH')
当由php-fpm
运行时,它返回
的/ usr / GNU / bin中:在/ usr / local / bin中:/ bin中:在/ usr / bin中:
在cli
中由bash
运行时,它会返回
的/ opt / local / bin中:/选择/ local / sbin中:在/ usr / local / bin中:在/ usr / bin中:/ bin中:/ usr / sbin目录:/ sbin目录中:/ opt / local / bin中:/选择/ local / sbin中
system
执行sh
而非bash
的命令,但MacPorts
添加
export PATH =“/ opt / local / bin:/ opt / local / sbin:$ PATH”
到~/.profile
和php-fpm
由nobody
而不是我当前的用户运行,因此导出不会影响php-fpm
。
我知道我可以将PATH从导出添加到/etc/profile
或/etc/paths
。
但在MacPorts
的情况下,哪种方式更安全。我不想破坏原生OS X
功能或导致与MacPorts
冲突。
修改:
更改/etc/profile
或/etc/paths
实际上没有帮助,system
仍然看不到/opt/local/bin/
中的程序:
sh:mysql:找不到命令
答案 0 :(得分:0)
你走在正确的道路上(看看我在那里做了什么?)
编辑/etc/paths
是解决方案,但您不仅仅是在寻找/opt/local/bin/
。 mysql
二进制文件(假设MySQL 5.5)存储在/opt/local/lib/mysql55/bin/mysql
中。 MacPorts中有许多这样的路径:
/opt/local/bin/
/opt/local/sbin/
/opt/local/apache2/bin/
/opt/local/lib/mysql55/bin/
/opt/local/lib/php/pear/bin/
答案 1 :(得分:0)
唯一有效的方法是将env[PATH]
中的/opt/local/etc/php56/php-fpm.conf
设置为echo $PATH
的结果