如何将 XDebug zend_extension 添加到 php.ini?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24657939/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 17:25:52  来源:igfitidea点击:

How to add XDebug zend_extension to php.ini?

phpxdebug

提问by Nate

I have a VPS with cPanel WHM and am trying to enable XDebug. I installed the extension by going to WHM -> Software -> Module Installers -> PHP Pecl -> Manageand I confirmed it's installed by checking my phpinfo()page.

我有一个带有 cPanel WHM 的 VPS,并且正在尝试启用 XDebug。我通过转到安装了扩展程序,WHM -> Software -> Module Installers -> PHP Pecl -> Manage并通过检查我的phpinfo()页面确认它已安装。

The next step is to enable XDebug in my php.ini file, but I'm a little confused how I should go about doing this.

下一步是在我的 php.ini 文件中启用 XDebug,但我有点困惑我应该如何去做。

Looking at php.ini in /usr/local/lib, I see this line at the bottom:

查看 php.ini 中/usr/local/lib,我在底部看到这一行:

zend_extension="/usr/local/Zend/lib/Guard-6.0.0/php-5.4.x/ZendGuardLoader.so"

However, in WHM -> Service Configuration -> PHP Configuration Editor, there's a "zend_extension" option with this value:

但是,在 WHM -> 服务配置 -> PHP 配置编辑器中,有一个带有此值的“zend_extension”选项:

/usr/local/IonCube/ioncube_loader_lin_5.4.so, /usr/local/Zend/lib/Guard-6.0.0/php-5.4.x/ZendGuardLoader.so

So my question is, how should I go about adding the path to XDebug:

所以我的问题是,我应该如何将路径添加到 XDebug:

/usr/local/lib/php/extensions/no-debug-non-zts-20100525/xdebug.so

To php.ini? I see three ways of doing it and I don't know which is correct:

到php.ini?我看到了三种方法,但我不知道哪个是正确的:

  1. I could add it to the comma separated list in WHM
  2. I could add it in php.ini directly, putting a comma between it and the existing value
  3. I could put it on a new line in php.ini
  1. 我可以将它添加到 WHM 中的逗号分隔列表中
  2. 我可以直接将它添加到 php.ini 中,在它和现有值之间加一个逗号
  3. 我可以把它放在 php.ini 的新行上

Which way is correct?

哪种方式是正确的?

回答by Fleshgrinder

Highly depends on the PHP configuration (./configure). PHP will look in the default extension path for your xdebug.soextension; in which case you don't need to specify any path:

高度依赖于 PHP 配置 ( ./configure)。PHP 将查找您的xdebug.so扩展的默认扩展路径;在这种情况下,您不需要指定任何路径:

zend_extension = xdebug.so

Regarding new line and comma, I prefer new line because it makes it easier to remove an extension later on. My php.inilooks like this (example):

关于换行和逗号,我更喜欢换行,因为这样可以更轻松地稍后删除扩展名。我php.ini看起来像这样(示例):

extension      = memcached.so
extension      = zopfli.so
zend_extension = opcache.so
zend_extension = xdebug.so

Notice the alphabetical order as well.

还要注意字母顺序。

回答by salah-1

You can add at the bottom of the file like the following:

您可以在文件底部添加如下内容:

zend_extension="/absolute/path/to/xdebug.so"

In my case, i put it in

就我而言,我把它放进去

zend_extension = /usr/lib64/php/modules/xdebug.so

However If you want to use Xdebug and OPCache together, you must have the zend_extension line for Xdebug after the line for OPCache. Otherwise, they won't work properly. See: https://xdebug.org/docs/install

但是,如果您想同时使用 Xdebug 和 OPCache,则在 OPCache 行之后必须有 Xdebug 的 zend_extension 行。否则,它们将无法正常工作。请参阅:https: //xdebug.org/docs/install