php PHP7 CLI 尝试加载 xdebug 两次 - “无法加载 Xdebug - 它已经加载”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/41741092/
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
PHP7 CLI attempts to load xdebug twice - "Cannot load Xdebug - it was already loaded"
提问by bcmcfc
After upgrading Ubuntu from 14.04 to 16.04, PHP CLI started complaining about xdebug:
将 Ubuntu 从 14.04 升级到 16.04 后,PHP CLI 开始抱怨 xdebug:
$ php -v
Cannot load Xdebug - it was already loaded
PHP 7.0.13-0ubuntu0.16.04.1 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.13-0ubuntu0.16.04.1, Copyright (c) 1999-2016, by Zend Technologies
with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans
There is only one .ini file:
只有一个 .ini 文件:
$ ls -la /etc/php/7.0/cli/conf.d/ | grep xdebug
lrwxrwxrwx 1 root root 38 Jan 19 11:41 20-xdebug.ini -> /etc/php/7.0/mods-available/xdebug.ini
And it's only referenced once in this output from php -i
:
它在以下输出中仅被引用一次php -i
:
$ php -i | grep -i configuration
Cannot load Xdebug - it was already loaded
Configuration File (php.ini) Path => /etc/php/7.0/cli
Loaded Configuration File => /etc/php/7.0/cli/php.ini
Configuration
And there's only one reference to xdebug in the entire directory (so it's not being included twice):
并且整个目录中只有一个对 xdebug 的引用(因此它不会被包含两次):
/etc/php/7.0$ grep -r xdebug *
mods-available/xdebug.ini:zend_extension=xdebug.so
mods-available/xdebug.ini:[xdebug]
mods-available/xdebug.ini:xdebug.remote_enable=1
mods-available/xdebug.ini:xdebug.remote_autostart=1
mods-available/xdebug.ini:xdebug.remote_port=9000
mods-available/xdebug.ini:xdebug.idekey=PHPSTORM
If I do $ phpdismod xdebug
I get the following output, suggesting that it still has xdebug loaded:
如果我这样做,$ phpdismod xdebug
我会得到以下输出,表明它仍然加载了 xdebug:
$ php -v
PHP 7.0.13-0ubuntu0.16.04.1 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.13-0ubuntu0.16.04.1, Copyright (c) 1999-2016, by Zend Technologies
with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans
Having done that it is no longer present in the apache config as shown by phpinfo()
.
完成后,它不再存在于 apache 配置中,如phpinfo()
.
How do I fix this?
我该如何解决?
Edit:Additional output as requested:
编辑:按要求附加输出:
$ php --ini
Cannot load Xdebug - it was already loaded
Configuration File (php.ini) Path: /etc/php/7.0/cli
Loaded Configuration File: /etc/php/7.0/cli/php.ini
Scan for additional .ini files in: /etc/php/7.0/cli/conf.d
Additional .ini files parsed: /etc/php/7.0/cli/conf.d/10-mysqlnd.ini,
/etc/php/7.0/cli/conf.d/10-opcache.ini,
/etc/php/7.0/cli/conf.d/10-pdo.ini,
/etc/php/7.0/cli/conf.d/15-xml.ini,
/etc/php/7.0/cli/conf.d/20-bcmath.ini,
/etc/php/7.0/cli/conf.d/20-calendar.ini,
/etc/php/7.0/cli/conf.d/20-ctype.ini,
/etc/php/7.0/cli/conf.d/20-curl.ini,
/etc/php/7.0/cli/conf.d/20-dom.ini,
/etc/php/7.0/cli/conf.d/20-exif.ini,
/etc/php/7.0/cli/conf.d/20-fileinfo.ini,
/etc/php/7.0/cli/conf.d/20-ftp.ini,
/etc/php/7.0/cli/conf.d/20-gd.ini,
/etc/php/7.0/cli/conf.d/20-gettext.ini,
/etc/php/7.0/cli/conf.d/20-iconv.ini,
/etc/php/7.0/cli/conf.d/20-json.ini,
/etc/php/7.0/cli/conf.d/20-mbstring.ini,
/etc/php/7.0/cli/conf.d/20-mcrypt.ini,
/etc/php/7.0/cli/conf.d/20-mysqli.ini,
/etc/php/7.0/cli/conf.d/20-pdo_mysql.ini,
/etc/php/7.0/cli/conf.d/20-pdo_sqlite.ini,
/etc/php/7.0/cli/conf.d/20-phar.ini,
/etc/php/7.0/cli/conf.d/20-posix.ini,
/etc/php/7.0/cli/conf.d/20-readline.ini,
/etc/php/7.0/cli/conf.d/20-shmop.ini,
/etc/php/7.0/cli/conf.d/20-simplexml.ini,
/etc/php/7.0/cli/conf.d/20-sockets.ini,
/etc/php/7.0/cli/conf.d/20-sqlite3.ini,
/etc/php/7.0/cli/conf.d/20-sysvmsg.ini,
/etc/php/7.0/cli/conf.d/20-sysvsem.ini,
/etc/php/7.0/cli/conf.d/20-sysvshm.ini,
/etc/php/7.0/cli/conf.d/20-tokenizer.ini,
/etc/php/7.0/cli/conf.d/20-wddx.ini,
/etc/php/7.0/cli/conf.d/20-xdebug.ini,
/etc/php/7.0/cli/conf.d/20-xmlreader.ini,
/etc/php/7.0/cli/conf.d/20-xmlwriter.ini,
/etc/php/7.0/cli/conf.d/20-xsl.ini
$ cat /etc/php/7.0/mods-available/xdebug.ini
zend_extension=xdebug.so
[xdebug]
xdebug.remote_enable=1
xdebug.remote_autostart=1
xdebug.remote_port=9000
xdebug.idekey=PHPSTORM
As this is still an issue I have found some further detail:
由于这仍然是一个问题,我发现了一些进一步的细节:
Paths:
路径:
$ ls -la /usr/bin/php
lrwxrwxrwx 1 root root 21 Apr 18 2017 /usr/bin/php -> /etc/alternatives/php
$ ls -la /etc/alternatives/php
lrwxrwxrwx 1 root root 15 Feb 12 15:43 /etc/alternatives/php -> /usr/bin/php7.1
php:
php:
$ php -v
Cannot load Xdebug - it was already loaded
PHP 7.1.15-1+ubuntu16.04.1+deb.sury.org+2 (cli) (built: Mar 6 2018 11:10:13) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.1.15-1+ubuntu16.04.1+deb.sury.org+2, Copyright (c) 1999-2018, by Zend Technologies
with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans
php7.1:
php7.1:
$ php7.1 -v
PHP 7.1.15-1+ubuntu16.04.1+deb.sury.org+2 (cli) (built: Mar 6 2018 11:10:13) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.1.15-1+ubuntu16.04.1+deb.sury.org+2, Copyright (c) 1999-2018, by Zend Technologies
with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans
The interesting thing there is that the php binary is identical to php7.1 but when called as the specific it doesn't show the already loaded message.
有趣的是,php 二进制文件与 php7.1 相同,但是当作为特定文件调用时,它不显示已加载的消息。
Edit, 20181006:
编辑,20181006:
I still have this issue. The image below is a diff of the output of the two php --ini
calls. As you can see, the sets of ini files loaded are the same.
我仍然有这个问题。下图是两次php --ini
调用输出的差异。如您所见,加载的 ini 文件集是相同的。
They are also the same symlinked binaries:
它们也是相同的符号链接二进制文件:
ben@ben-work:~$ which php
/usr/bin/php
ben@ben-work:~$ ls -la /usr/bin/php
lrwxrwxrwx 1 root root 21 May 15 16:07 /usr/bin/php -> /etc/alternatives/php
ben@ben-work:~$ ls -la /etc/alternatives/php
lrwxrwxrwx 1 root root 15 May 30 10:13 /etc/alternatives/php -> /usr/bin/php7.1
ben@ben-work:~$ which php7.1
/usr/bin/php7.1
回答by Magarusu
I've fixed this by removing zend_extension=xdebug.so
as I already enabled it in my docker container with docker-php-ext-enable xdebug
. It might be that it's enabled for you as well.
我已经通过删除zend_extension=xdebug.so
来解决这个问题,因为我已经在我的 docker 容器中使用docker-php-ext-enable xdebug
. 也可能是为您启用了它。
回答by dnloop
In Arch Linux the package xdebuggenerates the following configuration:
在 Arch Linux 中,包xdebug生成以下配置:
/etc/php/conf.d/xdebug.ini
----------
zend_extension=xdebug.so
xdebug.remote_enable=on
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
#xdebug.max_nesting_level=300
This loads twice the same zend_extension=xdebug.so
located in /etc/php/php.ini
这将加载两次相同的zend_extension=xdebug.so
位于/etc/php/php.ini
回答by farnoosh
I had the same issue and solved it by removing extra line of code zend_extension="xdebug.so"
inside php.ini file in the php folder that php --version showing, usually inside /usr/local/etc/php/
for mac users.
我遇到了同样的问题,并通过删除zend_extension="xdebug.so"
php --version 显示的 php 文件夹中的 php.ini 文件中的额外代码行来解决它,通常在/usr/local/etc/php/
mac 用户里面。
回答by vivoconunxino
Debian and derivate:
Debian 和衍生:
I fixed it locating my php.ini, changing the zend_extension=xdebug.so
to the old (so I guess the same would happend commenting the line) zend_extension_ts=zdebug.so
.
我修复了它,找到了我的 php.ini,将其更改zend_extension=xdebug.so
为旧的(所以我想评论该行也会发生同样的情况)zend_extension_ts=zdebug.so
。
Then with: php -i | grep xdebug
there should be only one conf.d with the zend_extension=xdebug.so
. If there were more than one delete the rest of entries.
然后与:php -i | grep xdebug
应该只有一个 conf.d 与zend_extension=xdebug.so
. 如果有多个,则删除其余条目。
回答by JonnieJS
For users who face the same problem.
对于面临同样问题的用户。
In my scenario, it was problem with php cli
so every time I tried to get to php in the console, I was getting notice: Cannot load the ionCube PHP Loader - extension already loaded
在我的场景中,这是有问题的,php cli
所以每次我尝试在控制台中访问 php 时,我都会收到通知:Cannot load the ionCube PHP Loader - extension already loaded
I guess it will be similar to other extensions.
我想它会类似于其他扩展。
What I have finally done is:
我最后做的是:
cd /opt/cpanel/ea-php56/root/etc
grep -r "cube" .
# now I saw two files loading the .so files:
# ./php.d/01-ioncube.ini:zend_extension="/opt/cpanel/ea-php56/root/usr/lib64/php/modules/ioncube_loader_lin_5.6.so"
# ./php.d/pecl.ini:zend_extension="/opt/cpanel/ea-php56/root/usr/lib64/php/modules/ioncube_loader_lin_5.6.so"
mv php.d/pecl.ini .
That was it.
就是这样。
回答by LeoLopez
You need serch the zend_extension declaration in your PHP config dir, for example
例如,您需要在 PHP 配置目录中搜索 zend_extension 声明
grep -Hnir zend_extension /etc/php/7.2/
The command will tell you where you the files:line where is defined the extension, in my case:
该命令将告诉您 files:line 定义扩展名的位置,在我的情况下:
/etc/php/7.2/mods-available/xdebug.ini:2:zend_extension=/usr/lib/php/20170718/xdebug.so
/etc/php/7.2/cli/php.ini:1938:; zend_extension = /usr/lib/php/20170718/xdebug.so
/etc/php/7.2/apache2/php.ini:368:zend_extension = /usr/lib/php/20170718/xdebug.so
Here, both cli/php.ini
and apache2/php.ini
are the same config file but mods-available/xdebug.ini
is another file with only xdebug info.
在这里,cli/php.ini
和apache2/php.ini
都是相同的配置文件,但mods-available/xdebug.ini
只是另一个只有 xdebug 信息的文件。
You can comment out or move the lines about xdebug in your php.ini to xdebug.ini and create a joined config under [xdebug]
section.
您可以将 php.ini 中关于 xdebug 的行注释掉或移动到 xdebug.ini 并在[xdebug]
部分下创建一个加入的配置。
Example:
例子:
#xdebug.ini
[xdebug]
zend_extension=/usr/lib/php/20170718/xdebug.so
xdebug.collect_params=4
xdebug.collect_vars=on
xdebug.remote_autostart=on
xdebug.var_display_max_children=128
xdebug.var_display_max_data=4086
xdebug.var_display_max_depth=10