将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
只有一个.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
它仅在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
在整个目录中只有一个对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
如果我$ 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
完成此操作后,它不再出现在phpinfo()
所示的apache配置中。
我该如何解决这个问题?
编辑:根据要求提供其他输出:
$ 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
由于这仍是一个问题,我已经找到了一些更详细的信息:
路径:
$ 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 -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 -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
有趣的是,php二进制文件与php7.1完全相同,但是当它被称为特定时,它不会显示已加载的消息。
编辑,20181006:
我还有这个问题。下图是两个php --ini
调用输出的差异。如您所见,加载的ini文件集是相同的。
它们也是符号链接的二进制文件:
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
答案 0 :(得分:10)
我已经通过移除public class WebViewActivity extends Activity{
private WebView webView;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.webview);
webView = (WebView) findViewById(R.id.webView1);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("http://www.google.com");
}
}
来解决这个问题,因为我已经在zend_extension=xdebug.so
的Docker容器中启用了它。它可能也是为你启用的。
答案 1 :(得分:3)
例如,您需要在PHP配置目录中查询zend_extension声明
grep -Hnir zend_extension /etc/php/7.2/
在我的情况下,该命令将告诉您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
此处,cli/php.ini
和apache2/php.ini
都是相同的配置文件,而mods-available/xdebug.ini
是另一个仅包含xdebug信息的文件。
您可以将php.ini中有关xdebug的行注释掉或移至xdebug.ini,并在[xdebug]
部分下创建一个合并的配置。
示例:
#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
答案 2 :(得分:2)
Debian和衍生:
我修复了它找到我的php.ini,将zend_extension=xdebug.so
更改为旧版本(所以我想同样会发生评论该行)zend_extension_ts=zdebug.so
。
然后使用:php -i | grep xdebug
,只有一个conf.d与zend_extension=xdebug.so
。如果有多个条目删除其余条目。
答案 3 :(得分:1)
面向面临相同问题的用户。
在我的情况下, php cli
存在问题,因此每次我尝试在控制台中使用php时,我都会注意到: Cannot load the ionCube PHP Loader - extension already loaded
< / strong>
我想它将与其他扩展类似。
我最后要做的是:
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 .
就是这样。
答案 4 :(得分:1)
我遇到了同样的问题,并通过删除php --version显示的php文件夹中的php.ini文件中的多余代码zend_extension="xdebug.so"
(对于Mac用户通常在/usr/local/etc/php/
内)解决了该问题。 / p>
答案 5 :(得分:1)
在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
这会加载位于zend_extension=xdebug.so
中的同一/etc/php/php.ini
的两倍