为什么 xdebug 在 apache 中不起作用 [英] why xdebug doesn't work in apache

查看:50
本文介绍了为什么 xdebug 在 apache 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

/var/www/html/index.php

/var/www/html/index.php

<?php
   echo 'a';
   echo 'a';

当 index.php 在 cli 模式下执行时

when index.php is execute in cli mode as below

$ php /var/www/html/index.php

xdebug 工作正常

xdebug worked fine

但是,当像 apache 这样执行时

However, when execute by apache like

$ curl 'http://localhost:80?XDEBUG_SESSION_START=1'
aa

xdebug 什么也没发生.

nothing happened to xdebug.

下面是apache的错误日志,没什么特别的

Below is the error log of apache, nothing special

1 [Fri Jun 17 05:02:15.526773 2016] [mpm_prefork:notice] [pid 30840] AH00163: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.17 配置——恢复正常运行│限定域名,使用 10.0.2.15.设置服务器名称"目录2 [Fri Jun 17 05:02:15.526839 2016] [core:notice] [pid 30840] AH00094:命令行:'/usr/sbin/apache2'

1 [Fri Jun 17 05:02:15.526773 2016] [mpm_prefork:notice] [pid 30840] AH00163: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.17 configured -- resuming normal operations │ qualified domain name, using 10.0.2.15. Set the 'ServerName' dir 2 [Fri Jun 17 05:02:15.526839 2016] [core:notice] [pid 30840] AH00094: Command line: '/usr/sbin/apache2'

我在 Vagrant 虚拟机中使用 Apache/2.4.7、PHP/5.5.9、Ubuntu、vim 和 DBGPavim.如何找出 xdebug 无法通过 apache 工作的原因?

I'm using Apache/2.4.7 , PHP/5.5.9 , Ubuntu , vim and DBGPavim in Vagrant virtual machine. How can I find out the reason why xdebug doesn't work via apache?

推荐答案

经过大量搜索,这终于对我有用了.希望这可以帮助 !

After a lot of searching, this is what finally worked for me. Hope this helps !

我使用的是 PHP 7.0.21、Zend Engine v3.0.0 和 Xdebug v2.5.0.我在重新启动 apache 之前运行了以下命令

I'm using PHP 7.0.21, Zend Engine v3.0.0 and Xdebug v2.5.0. I ran the following commands before restarting apache

# Step 1 : In xdebug.ini or php.ini enable xdebug
sed -i 's/;zend_extension=xdebug.so/zend_extension=xdebug.so/' /etc/php7/conf.d/xdebug.ini
echo -e "xdebug.remote_enable=1\nxdebug.remote_handler=dbgp\nxdebug.remote_mode=req\nxdebug.remote_host=127.0.0.1\nxdebug.remote_port=9000" >> /etc/php7/conf.d/xdebug.ini

# Step 2: Copy the php + xdebug configuration files to apache
cp /etc/php7/php.ini /etc/apache2/ && \
cp /usr/lib/php7/modules/xdebug.so /usr/lib/apache2 && \
cp /etc/php7/conf.d/xdebug.ini /etc/apache2/conf.d/ && \

修复后我的文件布局是

/etc
|--php7
|     |-- php.ini
|     |-- conf.d
|              |-- xdebug.ini
|--apache2
|     |--php.ini
|     |-- conf.d
|              |-- xdebug.ini


/usr/lib
|--php7
|    |--modules
|          |--xdebug.so
|--apache2
|    |--modules
|          |--xdebug.so

发现 这个 文档真的很有帮助.

Found this document really helpful.

这篇关于为什么 xdebug 在 apache 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆