以下是我如何通过多个 PHP-FPM 自制程序安装使其工作。
我将这篇出色的文章用于多次安装:
https://echo.co/blog/os-x-1010-yosemite-local-development-environment-apache-php-and-mysql-homebrew
在那篇文章的 cmets 中,您会看到推荐的如何安装 xdebug,底线:
brew install php56-xdebug
您必须为已安装的每个 PHP 版本安装 xdebug。 Homebrew 将为您安装的每个 php 版本生成一个 xdebug.ini 文件。每个都有如下路径:
/usr/local/etc/php/<version # i.e. "5.6">/conf.d/ext-xdebug.ini
本文安装了在 xdebug 的默认端口 (9000) 上运行的 DNSMasq,因此您需要将 xdebug 端口更改为其他端口(9001 可以正常工作。)
编辑上面提到的 ext-xdebug.ini 文件(如果您安装了多个版本的 php,则编辑文件。)这对我有用:
[xdebug]
zend_extension="/usr/local/opt/php56-xdebug/xdebug.so"
; General config
; Dumps local variables on exception
xdebug.show_local_vars=On
; Dump server variables
xdebug.dump.SERVER=*
; Dump global variables
xdebug.dump_globals=On
xdebug.collect_params=4;
; Tracing
;xdebug.auto_trace=On
;xdebug.trace_output_dir= /opt/local/php_traces/
xdebug.show_mem_delta=On
xdebug.collect_return=On
; Debugging. You might need to specify your host with some additional options
xdebug.remote_enable=1
: from http://devzone.zend.com/1147/debugging-php-applications-with-xdebug/
xdebug.remote_host="localhost"
xdebug.remote_port=9001
xdebug.remote_handler="dbgp"
前两行是原始自制文件中的全部内容。
顺便说一句——当我安装了多个 PHP 版本时,这个 ext-xdebug.ini 文件只是为我安装的第一个 PHP 版本创建的。我只是将此文件复制到其他 PHP 版本位置,并更改了第 2 行中路径的“php56-xdebug”部分以反映正确的 php 版本。
注意“xdebug.remote_port=9001”
然后在 Netbeans 中(我使用的是 8.02 Mac osX10.10.3)我使用以下设置。
转到首选项-> PHP->调试
调试器端口:9001
在第一行停止:(未选中)
手表和气球评估:(选中 - 有一个警告,但对我来说效果很好。)
另外值得注意的是,为了使用 phpinfo()(或命令行 php -i)显示 xdebug,我需要使用以下命令重新启动 apache:
launchctl unload -Fw ~/Library/LaunchAgents/homebrew.mxcl.php56.plist
sudo apachectl restart
launchctl load -Fw ~/Library/LaunchAgents/homebrew.mxcl.php56.plist
由于某种原因,我的设置要求我每次启动时都运行它。有点痛苦,但我将它合并到一个 shell 命令中以便在版本之间轻松切换。
另一个提示:brew info php56 的一部分说:
OS X 10.8 and newer come with php-fpm pre-installed, to ensure you are using
the brew version you need to make sure /usr/local/sbin is before /usr/sbin
in your PATH:
PATH="/usr/local/sbin:$PATH"
在我将它添加到我的 .profile_bash 文件之前,我对每个版本的 php-fpm.conf 文件所做的更改都无法识别。其他一切似乎都有效,所以很混乱。
希望这可以节省其他人的时间和麻烦。