23

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

Irfan DANISH
  • 8,349
  • 12
  • 42
  • 67
mahen3d
  • 7,047
  • 13
  • 51
  • 103
  • Have you tried this ? http://www.somacon.com/p520.php ? Also my php.ini for command line is located in /etc/php5/cli/php.ini . Maybe you have also an other configuration somewhere else – Asenar Oct 29 '13 at 09:15

8 Answers8

15

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
Jenson M John
  • 5,499
  • 5
  • 30
  • 46
  • 2
    as i said in my question, i dont have that line in my php.ini so where shodul i look to ? – mahen3d Oct 29 '13 at 09:33
  • You probably looking @ wrong php.ini. Have you tried php -i | grep php.ini ? – Jenson M John Oct 29 '13 at 09:34
  • no there is only one and only php.ini file, output for yoru command is 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 – mahen3d Oct 30 '13 at 07:13
  • 1
    @mahen3d , it is probably loaded in from another, ini file dedicated to memcache, so check something like /etc/php5/cli/conf.d/memcache.ini – Mart Van de Ven May 03 '14 at 07:39
15

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.

cristi2091
  • 191
  • 1
  • 4
5

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
    
Kalle Richter
  • 8,008
  • 26
  • 77
  • 177
2

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).
Allan Mwesigwa
  • 1,210
  • 14
  • 13
0

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
Shriganesh Shintre
  • 2,428
  • 3
  • 17
  • 16
0

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

0

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,

ubuntu@webserver:~$ 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

ubuntu@webserver:~$ sudo rm /etc/php5/fpm/conf.d/sphinx.ini
Hemant Thorat
  • 2,386
  • 20
  • 14
-1

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