我使用的是最新版本的PHP (7.0.2)
和xdebug (2.4.0RC3)
以及phpstorm 9.0.2
,当我开始调试时,我会立即得到
error "502 Bad Gateway"
有时我会设法遍历几行代码,但后来还是出现了错误。
当我有以前版本的PHP (5.6)
和xdebug
时,一切都很棒。
php、nginx和xdebug都是用自制软件安装的。
您可以尝试以下操作:打开你的php.ini,对不起,我不知道它在MacOS中的位置,在Ubuntu中它在上
/etc/php/7.0/fpm/php.ini
使用您喜爱的文本编辑器打开它,并具有保存配置文件所需的权限。转到xdebug部分,检查您是否正确设置了它。在我的情况下,它看起来像下面。请注意,在您的情况下,xdebug.so的路径可能不同。
[Xdebug]
zend_extension="/usr/lib/php/20151012/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.profiler_enable=1
xdebug.profiler_output_dir="'tmp"
xdebug.idekey="PHPSTORM"
xdebug.remote_autostart=1
xdebug.remote_host=192.168.10.10
xdebug.remote_mode=req
xdebug.remote_connect_back=1
xdebug.max_nesting_level=200
xdebug.var_display_max_depth=1000
xdebug.var_display_max_children=256
xdebug.var_display_max_data=4096
;this line below to prevent debug stop timeout
request_terminate_timeout=600s
在php.ini中要检查的另一件事是
max_execution_time = 600
如上所述,我将其设置为秒,以防止停止调试会话。默认情况下,它设置为30秒
接下来你需要检查的是nginx配置,我已经在nginx.confhttp主节中添加了行
http {
proxy_connect_timeout 600s;
proxy_send_timeout 600s;
fastcgi_read_timeout 600s;
proxy_read_timeout 600s;
fastcgi_buffers 8 16k;
fastcgi_send_timeout 600s;
fastcgi_buffer_size 32k;
#other standard settings below...
我添加它们是为了给我更多的时间调试会话,这样它就不会在600秒内停止。
经过所有编辑。重新启动php7.0-fpm和nginx。我不确定它是如何在Ubuntu的MacOS中完成的,它是通过完成的
sudo service php7.0-fpm reload
sudo service php7.0-fpm restart
sudo service nginx reload
sudo service nginx restart
也许重新加载然后重新启动是过分的,但要有保险:)
还可以查看nginx的error.log文件在Ubuntu中,它们被放在/var/logs/nginx/中出现错误。yourdomain.log到最后一行看看发生了什么。希望能有所帮助。
UPD:对于任何将Homestead与ngrok
隧道(例如ssh -R 3000:localhost:8000 user@yourserver.domain
,然后在公共站点上,您将在端口80上设置nginx作为somedomain的反向代理,通过SSH从3000隧道读取)一起使用Homestead的人,以向互联网公开本地开发。
要启用调试,您需要注释掉xdebug.remote_connect_back=1
行或将其值设置为0
。否则,xdebug将获得X-Forwarded-For
和其他标头,并尝试连接回nginx,但不连接到您的本地dev,调试将不会开始。
由于某种原因,当我从模式中删除profile
时,它会帮我修复它。
即更改
xdebug.mode=debug,develop,profile
至
xdebug.mode=debug,develop