doufan6544 2018-11-01 05:51
浏览 249
已采纳

安装后xdebug无法正常工作并设置php设置

I installed Xdebug on PHP 7.3 using pecl install xdebug

When I add these settings to /etc/php/7.3/apache2/php.ini and reload apache the page fails and says no data sent to server.

xdebug.var_display_max_children=-1
xdebug.var_display_max_data=-1
zend_extension="/usr/lib/php/20180731/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.halt_level=E_WARNING|E_NOTICE|E_USER_WARNING|E_USER_NOTICE
xdebug.scream=1

Not sure why its not working.

  • 写回答

2条回答 默认 最新

  • dongxiaoshe0737 2018-11-07 07:50
    关注

    (In the original version of your question, your configuration was commented out, now you've edited that bit out, leaving the next couple of paragraphs kinda out of the loop)

    Despite the documentation stating that the has character (#) is no longer recognized as a valid comment character since PHP 7.0:

    PHP Changelog

    it seems that php will happily treat those lines as commented nonetheless in configuration files. Everything afer the hash is ignored by the interpreter.

    So those configuration lines are completely ineffective.

    To verify that your configuration is being loaded, create a simple file like this:

    <php
    phpinfo();
    

    Loading this file will tell you everything about PHPs configuration. If Xdebug has been successfully loaded, you'll see something like this:

    phpinfo output

    And down below the configuration settings loaded:

    phpinfo output

    These are the most important settings, that actually load and enable the Xdebug extension:

    zend_extension="/usr/lib/php/20180731/xdebug.so"
    xdebug.remote_enable=1
    

    Important: You need to check that /usr/lib/php/20180731/xdebug.so actually exists, and if not find the actual location of your xdebug module.

    The next line assumes that the webserver and the browser are installed on the same machine on the same IP, which might be true for a simple setup:

     xdebug.remote_host=127.0.0.1
    

    As an alternative, you can tell Xdebug to connect back to whichever IP has made the orginal request

     xdebug.remote_connect_back=On
    

    With the following line you are telling on which port your IDE is listening to. It's 9000 by default, so you'll normally would not need to set it unless you need to listen to a non-standard port (e.g. debugging several projects at the same time, against different interpreters). But normally, you can omit this line safely:

    xdebug.remote_port=9000
    

    Once the module is loaded and enabled, you can also configure some Xdebug settings using an environment variable. Specifically xdebug.remote_host, xdebug.remote_port, xdebug.remote_mode and xdebug.remote_handler

    E.g:

    export XDEBUG_CONFIG="remote_host=192.168.0.3 remote_port=9005"
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?