PHP remove/fix module not found or already loaded warnings?

When i run a php script from the command line like below

php test.php

i get following output

PHP Warning:  Module 'memcache' already loaded in Unknown on line 0
PHP Warning:  Module 'apc' already loaded in Unknown on line 0

how do i fix or remove these module warnings ? I checked the php.ini in

etc/php.ini 

output of

php -i | grep php.ini
PHP Warning:  Module 'memcache' already loaded in Unknown on line 0
PHP Warning:  Module 'apc' already loaded in Unknown on line 0
Configuration File (php.ini) Path => /etc
Loaded Configuration File => /etc/php.ini

i dont see any loading or any reference to these two modules in there …

please help

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

I had the same situation. In my case the problem was that I had two configuration files for memcache in /etc/php5/cli/conf.d/.

php -i | grep memcache.ini

In my case the result was:

/etc/php5/cli/conf.d/20-memcache.ini,
/etc/php5/cli/conf.d/memcache.ini

To get rid of the warning message I removed the line extension=memcache.so from the memcache.ini file.

Solution 2

When you install php5-memcache it adds it’s own memcache.ini file which is set to load that extension already. So Just remove/comment the loading of the extension from your php.ini.

 ;extension=memcache.so

Similar with APC (Alternative PHP Cache Module).

 ;extension=apc.so

Solution 3

If you are using php5.4 (CentOS 6.5),

  • Goto /etc/php.d/
  • in memcache.ini comment the extension

    ;extension=memcache.so
    
  • likewise in apc.ini

    ;extension=apc.so
    

Solution 4

I came here looking for a solution to a similar error i.e. Warning: Module 'pdo_pgsql' already loaded in Unknown on line 0.
After looking at various sites, here’s the solution I came up with.
It worked for me, hope it does for someone with a similar issue.

  • Locate the folder conf.d, mine was in the directory
    /usr/local/etc/php/7.0/conf.d.
  • In this folder, there’s a file called ext-pdo_pgsql.ini.
  • Type sudo nano ext-pdo_pgsql.ini to edit it.
  • There should be a line extension="/usr/local/opt/php70-pdo-pgsql/pdo_pgsql.so". Comment it
    out by adding semi-colon to the beginning of the line i.e.
    ;extension="/usr/local/opt/php70-pdo-pgsql/pdo_pgsql.so".
  • Save the file. (I usually run control + O, control + M).
  • Exit the file (control + X).

Solution 5

Its possible that these modules are listed twice and so you get error “Already loaded”.
Find out which configuration files are loaded

php -i | grep 'Loaded Configuration File'
php -i | grep 'ini'

This will tell you which .ini files are loaded and parsed (Additional .ini files parsed).

Look at the specific files and comment out the second occurrence (as follows)

;extension=memcache.so
;extension=apc.so

Solution 6

there are configuration files modules /etc/php5/mods-available

Open file pdo_mysql.ini and comment line pdo_mysql.so

After service apache2 | php5-fpm restart depending on whether you are using you

Solution 7

I was getting same error,

Module 'sphinx' already loaded

You need to find module (.ini) which is getting loaded more than once and delete one of them,

[email protected]:~$ grep -R "sphinx" /etc/php5/*

/etc/php5/fpm/conf.d/sphinx.ini:extension=sphinx.so
/etc/php5/fpm/conf.d/20-sphinx.ini:extension=sphinx.so

[email protected]:~$ sudo rm /etc/php5/fpm/conf.d/sphinx.ini

Solution 8

if you dont whants to update in config file,
just add on top of your page or constructor “error_reporting(0)

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply