PHP module is already loaded warning
Asked Answered
W

8

7

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?

Wojcik answered 4/7, 2016 at 8:30 Comment(6)
It looks like your PHP installation could be loading two php.ini files or the same one twice, can you post your PHP.ini file on justpasteitGoldiegoldilocks
Thanks for your comment. Just posted my CLI php.ini is here.Wojcik
It shows all the comments are commented out, can you post the value of php -i from the command line to that site?Goldiegoldilocks
done :)Wojcik
Provide the link :pGoldiegoldilocks
lol wow I suck at this computer stuff at times. But this is kinda expected behavior looking at it I'll provide an answer below since the output could become long.Goldiegoldilocks
A
8

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.

Adamsite answered 15/6, 2017 at 16:36 Comment(1)
THANK YOU. Been looking for this for 2 days.Lozier
G
5

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.

Goldiegoldilocks answered 4/7, 2016 at 10:6 Comment(6)
Thank you for the answer! But you're assuming, that the extension={exname}.so statements are in the INI includes AND in the main php-ini. Right? But it's not like this -- the php.ini doesn't consist anything for loading extensions. It's why I'm wondering, that PHP tries to load them twice.Wojcik
Can you zip or tar /etc/php/7.0 and upload it. PHP uses different ini files for cli/cgi/apache/nginx/fpm. I can run it on my linux distro and hopefully fix this problem which has become personal :pGoldiegoldilocks
Thank you for still trying to help me & sorry for the delay! I zipped the entire /etc/php directory. (Of course all the symlinks has become independent files.) You can download it here.Wojcik
The /cli/php.ini file isn't in the archive. Reading through some posts online, it sounds like PHP is compiled with PDO already (my configuration uses it as an extension on php 5) so there's no reason to load it as an extension. However I was unable to find confirmation of this on the PHP website.Goldiegoldilocks
Sorry, I removed the php.ini for CLI to test something and then forgot to restore it. Added it now again to /etc/php/7.0/cli/ and to the archive in Dropbox. I also added the output of php -i as a file (php-i.txt in the archive's root).Wojcik
I see no issues with the configuration files, I'd report this as a bug here. Hopefully they'll be able to guide you in the right direction.Goldiegoldilocks
D
4

This happened to me when I installed the php-mbstring using sudo apt-get install php-mbstring and enabled extension=mbstring in my php.ini.

PHP look at two mbstring plugin. One in installed package, second in enabled package in php.ini

The solution is to disable the plugins in php.ini

;extension=bz2
;extension=curl
;extension=fileinfo
;extension=gd2
;extension=gettext
;extension=gmp
;extension=intl
;extension=imap
;extension=interbase
;extension=ldap
;extension=mbstring
Declan answered 10/6, 2020 at 19:52 Comment(0)
C
3

PHP is loading modules multiple times. Find and remove the extra php.ini file(s).

  1. Execute the following php file. It will print a lot of info about your php installation in a table:

.

<?php
phpinfo();
  1. In the table, find the entry for "Loaded Configuration File". It will tell you where php.ini is located. Go on disk and rename it php.ini.bak.
  2. Restart the server and execute the file above once again. "Loaded Configuration File" will tell you where the other php.ini is located. That's the duplicate.
  3. Backup and remove the duplicate. Re-instate the original, and you should be good to to.
Chartres answered 4/7, 2016 at 10:22 Comment(1)
Thank you, but it didn't work. Look: 1. php -r 'phpinfo(); echo PHP_EOL;' | grep "php.ini" -- output: line1 Configuration File (php.ini) Path => /etc/php/7.0/cli, line2 Loaded Configuration File => /etc/php/7.0/cli/php.ini. 2. mv /etc/php/7.0/cli/php.ini ~/Desktop/. 3. service php7.0-fpm restart. 4. php -r 'phpinfo(); echo PHP_EOL;' | grep "php.ini" -- output: onlie one line Configuration File (php.ini) Path => /etc/php/7.0/cli. And all the PHP Warning: Module 'gettext' already loaded in Unknown on line 0 stuff is still here.Wojcik
F
0

Check /etc/php5/apache2/php.ini and /etc/php5/cli/php.ini. You should not load in each php.ini in this directories the extension xdebug.so. Only one php.ini should load it. PHP Warning: Module already loaded in Unknown on line 0

Fubsy answered 16/11, 2016 at 2:44 Comment(1)
delete this: zend_extension="/usr/lib/php5/20******/xdebug.so" xdebug.remote_enable=1 xdebug.remote_autostart=1 xdebug.remote_handler=dbgp xdebug.remote_mode=req xdebug.remote_host=127.0.0.1 xdebug.remote_port=9000Fubsy
P
0

I had the same problem. I have updated my PHP Version and cleared off the issue.

For some reason, the problem originated because of an incoherent status of the composer.lock file. After a composer update (and of course running all my unit-tests to ensure nothing was broken), the error was gone and the composer run was clean.

Penley answered 22/10, 2017 at 6:45 Comment(0)
P
0

just a piece of hint for those people who landed on this page.

  • check the configuration files loaded with phpinfo();
  • check the configuration files loaded in terminal php -i command check both php.ini files above. only uncomment/enable the intl extension at php.ini shown at phpinfo() and comment/disable the line code in php.ini file shown by php -i The one which used for php configuration is the one from phpinfo()
  • don't forget to restart the webserver and php in my case I am using nginx and php 7.4. "sudo systemctl restart nginx" "sudo service php7.4-fpm restart"
Pam answered 5/3, 2021 at 2:35 Comment(0)
S
-1

Just downgrade your PHP version from the cpanel!

Sharpedged answered 15/8, 2020 at 17:26 Comment(1)
Please add some further explanation to your answer such that others can learn from it. What makes you think that cpanel is involved after all?Cloud

© 2022 - 2024 — McMap. All rights reserved.