首页 文章

为什么xdebug不能在apache中工作

提问于
浏览
1

/var/www/html/index.php

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

当index.php在cli模式下执行时,如下所示

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

xdebug工作得很好
enter image description here

但是,当由apache执行时

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

xdebug什么都没发生 .

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

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 . 设置'ServerName'目录2 [Fri Jun 17 05:02:15.526839 2016] [core:notice] [pid 30840] AH00094:命令行:'/ usr / sbin / apache2'

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

1 回答

  • 1

    我是PHP的新手,但经过大量的搜索,这才是我最终的工作 . 希望这可以帮助 !

    我使用的是PHP 7.0.21,Zend Engine v3.0.0和Xdebug v2.5.0 . 在重新启动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
    

    找到this文件确实很有帮助 .

相关问题