PHP module is already loaded warning

automatix picture automatix · Jul 4, 2016 · Viewed 26.3k times · Source

Just noticed, that PHP throws warnings, when executed on the CLI:

php module is already loaded

$ 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

I know, how to prevent them -- simply remove extension={extname}.so from the /etc/php/7.0/cli/conf.d/{extname}.ini files. But:

Is removing of this line in the INI files a solution or just a workaround to avoid the warning messages? Can any side effects occur due to this? Why does it happen / What is the issue actually caused by?

Answer

Anurag Kumar picture Anurag Kumar · Jun 15, 2017

You have probably loaded the shown extensions twice in your php.ini files.

You can search the folder /etc/php/7.0 where you will find php.ini files in its subfolders, most probably in :

  • /etc/php/7.0/cli/
  • /etc/php/7.0/apache2/

If you see some extension=something.so repeated twice in these php.ini files you can remove it from one or if still the warning shows remove from both.