刚刚注意到,当在 CLI 上执行时,PHP 会抛出警告:
php模块已经加载
$ php -v
PHP Warning: Module 'PDO' already loaded in Unknown on line 0
PHP Warning: Module 'calendar' already loaded in Unknown on line 0
PHP Warning: Module 'ctype' already loaded in Unknown on line 0
PHP Warning: Module 'exif' already loaded in Unknown on line 0
PHP Warning: Module 'fileinfo' already loaded in Unknown on line 0
PHP Warning: Module 'ftp' already loaded in Unknown on line 0
PHP Warning: Module 'gettext' already loaded in Unknown on line 0
PHP Warning: Module 'iconv' already loaded in Unknown on line 0
PHP Warning: Module 'Phar' already loaded in Unknown on line 0
PHP Warning: Module 'posix' already loaded in Unknown on line 0
PHP Warning: Module 'shmop' already loaded in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/sockets.so' - /usr/lib/php/20151012/sockets.so: undefined symbol: php_network_gethostbyname in Unknown on line 0
PHP Warning: Module 'sysvmsg' already loaded in Unknown on line 0
PHP Warning: Module 'sysvsem' already loaded in Unknown on line 0
PHP Warning: Module 'sysvshm' already loaded in Unknown on line 0
PHP Warning: Module 'tokenizer' already loaded in Unknown on line 0
PHP 7.0.3-5+deb.sury.org~trusty+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.6-dev, Copyright (c) 1999-2016, by Zend Technologies
with Xdebug v2.4.0RC4, Copyright (c) 2002-2016, by Derick Rethans
我知道,如何防止它们——只需从 /etc/php/7.0/cli/conf.d/{extname}.ini
文件中删除 extension={extname}.so
。但:
删除 INI 文件中的这一行是解决方案还是只是避免警告消息的解决方法?会因此产生任何副作用吗?为什么会发生/问题实际上是由什么引起的?
原文由 automatix 发布,翻译遵循 CC BY-SA 4.0 许可协议
您可能已经在 php.ini 文件中加载了两次显示的扩展。
您可以搜索文件夹 /etc/php/7.0,您会在其中的子文件夹中找到 php.ini 文件,最有可能位于:
如果您看到某些 extension=something.so 在这些 php.ini 文件中重复了两次,您可以将其从一个文件中删除,或者如果警告仍然显示从两个文件中删除。