可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
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
回答1:
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
回答2:
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.
回答3:
If you are using php5.4 (CentOS 6.5),
回答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).
回答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
回答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
回答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,
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
回答8:
if you dont whants to update in config file,
just add on top of your page or constructor "error_reporting(0)"