Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP module is already loaded warning

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?

like image 845
automatix Avatar asked Jul 04 '16 08:07

automatix


Video Answer


2 Answers

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.

like image 56
Anurag Kumar Avatar answered Sep 21 '22 18:09

Anurag Kumar


PHP on Linux usually scans subfolders for more configuration files, which is what happened in this case.

Configuration File (php.ini) Path => /etc/php/7.0/cli Loaded
Configuration File => /etc/php/7.0/cli/php.ini Scan this dir for additional .ini files => /etc/php/7.0/cli/conf.d 
Additional .ini files parsed => 
  /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/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-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-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-mcrypt.ini,
  /etc/php/7.0/cli/conf.d/20-mongodb.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-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-xdebug.ini,
  /etc/php/7.0/cli/conf.d/20-xsl.ini

Little walk through PHP scanned the folder /etc/php/7.0/cli/ and found a php.ini which told it there should be more configuration (ini) files in a subdirectory called conf.d and each module has its own ini file typically on Linux and in the later version of PHP.

To answer the question "Is removing of this line in the INI files a solution or just a workaround to avoid the warning messages?"

Honestly I like having the configuration for each module in a separate file, but you could remove the files in conf.d if you wish to configure the module in the php.ini file. I just find that it gets cluttered.

like image 36
Philip Rollins Avatar answered Sep 21 '22 18:09

Philip Rollins