在CentOS 6.4上使用Xdebug进行远程调试

3

我尝试使用phpstorm进行远程调试php应用程序。我在vmware虚拟机上使用centos 6.4、php5.3和apache 2.2,并在真实的ubuntu上使用firefox与phpstorm配合使用。 xdebug确实已经安装:

Installed Packages
Name        : php-pecl-xdebug
Arch        : i686
Version     : 2.1.4
Release     : 1.el6
Size        : 580 k
Repo        : installed
From repo   : epel
Summary     : PECL package for debugging PHP scripts
URL         : http://pecl.php.net/package/xdebug
License     : PHP

并且phpinfo也确认了这一点:

This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
    with Xdebug v2.1.4, Copyright (c) 2002-2012, by Derick Rethans

当我通过ssh从控制台运行脚本(简单的hello world)时,我的脚本停止运行,我从xdebug获取mu ide的连接并在自己的日志中编写信息。 但是当我从浏览器运行脚本时-没有效果,即使在xdebug日志中也没有。 我尝试使用firefox扩展程序启动调试会话,尝试使用xdebug.remote_autostart = 1选项,关闭centos中的iptables,但也没有效果。 我做错了什么? xdebug配置:

; Enable xdebug extension module
zend_extension=/usr/lib/php/modules/xdebug.so
;xdebug.remote_host=10.0.0.1
xdebug.remote_connect_back=1
xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
;xdebug.remote_mode=req
;xdebug.profiler_enable=1
;xdebug.profiler_enable_trigger=1
;xdebug.remote_autostart=1
;xdebug.idekey=PHPSTORM
xdebug.remote_log="/tmp/xdebug.log"
2个回答

6

天啊,问题解决了。原来是 selinux 的问题。

执行 setsebool httpd_can_network_connect=1 命令,重启 nttpd - 这样 phpstorm 就可以从 xdebug 获取连接了。


你好,能否详细说明一下你的答案?我也在尝试实现同样的功能,但迄今为止还没有成功。谢谢。 - MrCujo
你有同样的问题吗?xdebug可以从控制台脚本获取连接,但在通过HTTP服务器执行脚本时无法获取连接?而且你是在Redhat/CentOS/Fedora(带SELinux系统)上工作吗? - Hayate
是的,没错。我的虚拟机服务器使用的是Centos 7操作系统,而我的主机是OS X。 - MrCujo
好的,我所有的操作都是从VM控制台中输入两个命令:setsebool httpd_can_network_connect=1然后service httpd restart这些命令是否执行无误? - Hayate

0

etc/selinux/config更改

  • 此文件控制系统上SELinux的状态。

  • SELINUX=可以取这三个值之一:

  • enforcing - 执行SELinux安全策略。

  • permissive - SELinux打印警告而不是执行。

  • disabled - 没有加载SELinux策略。 SELINUX=enforcing

  • SELINUXTYPE=可以取这三个值之一:

  • targeted - 受保护的目标进程,

  • minimum - 修改有针对性的策略。只有选定的进程受到保护。

  • mls - 多级安全保护。

SELINUXTYPE=targeted

  • 该文件控制系统上SELinux的状态。

  • SELINUX=可以取这三个值中的一个:

  • enforcing - 执行SELinux安全策略。

  • permissive - SELinux打印警告而不执行。

  • disabled - 没有加载SELinux策略。

SELINUX=disabled

  • SELINUXTYPE=可以取这三个值中的一个:

  • targeted - 受保护的进程为目标进程,

  • minimum - 有选择性地保护特定进程的策略修改。

  • mls - 多级安全保护。

SELINUXTYPE=targeted


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接