doubi7346 2017-11-07 19:54
浏览 135
已采纳

xdebug.ini和php.ini有什么区别

Recently I installed lamp and php-xdebug on an ubuntu 16.04 box. I noticed that now I have the following files

/etc/php/7.0/apache2/conf.d/20-xdebug.ini

/etc/php/7.0/cli/conf.d/20-xdebug.ini

/etc/php/7.0/mods-available/xdebug.ini

I was wandering what is the difference is between these files and settings in /etc/php/7.0/apache2/php.ini are affected by these.

Also in terms of best practice which of these files should be used?

If configurations are repeated in these files with different values which would take precedence?

For example if xdebug.remote_port = 9000 is set in /etc/php/7.0/apache2/php.ini and in /etc/php/7.0/mods-available/xdebug.ini it was set as xdebug.remote_port = 9001 which value would be selected?

  • 写回答

2条回答 默认 最新

  • dongzan2740 2017-11-07 20:56
    关注

    Ubuntu is based on Debian. Debian and it's derivatives use a somewhat unique way of managing extensions for php and apache.

    Of the files you have listed:

    • /etc/php/7.0/apache2/conf.d/20-xdebug.ini is a symlink to /etc/php/7.0/mods-available/xdebug.ini

    • /etc/php/7.0/cli/conf.d/20-xdebug.ini is also a symlink to /etc/php/7.0/mods-available/xdebug.ini

    • You can edit /etc/php/7.0/mods-available/xdebug.ini directly and changes you make will affect everywhere it is enabled.

    Commands phpenmod and phpdismod are available do enable or disable PHP modules. These are like a2enmod for apache, which you can read about here. For example, turn XDebug off with sudo phpdismod xdebug. Turn it back on with sudo phpenmod xdebug. Your configuration will be preserved when you flip it on and off because your changes are always preserved in mods-available, although PHP does not look in that directory for configuration. In fact, when you "disable" the module with phpdismod, it's simply removing the symlink from the appropriate folder so that the module is not enabled in the php config.

    Finally, /etc/php/7.0/apache2/php.ini is the location for system-wide config that is not a module that can be enabled or disabled.


    Thus, your config changes like xdebug.remote_port = 9000 should go in /etc/php/7.0/mods-available/xdebug.ini since it's related to XDebug. Putting it in both places is a bad idea (because of the confusion it creates), but the last one to load takes precedence. This is why many of the files in the mods-available directory have numbers in the filename - so they'll load in the correct order.

    Use the phpinfo() function to get more info about which config values were loaded and what ini files they were loaded from. For example:

    $ php -r "phpinfo();"
    

    or

    $ php -r "phpinfo();" | grep xdebug
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型