How to Fix PHP Warning: Module already loaded in Unknown on line 0 on Ubuntu

mysql.ini

I received email from cronjob saying that there was PHP module already loaded:

PHP Warning: ย Module 'mysql' already loaded in Unknown on line 0

This warning happens when there is PHP extension loaded more than once. To fix this problem, check /etc/php5/apache2/php.ini file and the corresponding module configuration file in /etc/php5/conf.d/. For mysql module, I found it loaded 2 times in /etc/php5/apache2/php.ini and /etc/php5/conf.d/mysql.ini. Deactivate one module will settle the problem.

I also found that mysql.so extension is loaded 2 times on /etc/php5/cli/php.ini and /etc/php5/cli/conf.d/mysql.ini

I put ; (semi colon)ย  in front of the line in /etc/php5/conf.d/mysql.ini

mysql.ini

15 thoughts on “How to Fix PHP Warning: Module already loaded in Unknown on line 0 on Ubuntu

    1. Ubuntu has cronjob to check PHP modules regularly. If a problem found, such as multiple module loaded, it will send email notification to server administrator.

  1. @Reza
    The cron is probably using wget -O. An alternative Cron command line command that is safer to use is lynx -source instead of wget -O. You would simply replace the wget command line with lynx -source.

  2. I’m wondering why you chose to disable the conf.d instance, and not the apache one.

    The reason I ask is conf.d is linked (in my case anyway) to several sub php instances (apache2, cli, cgi, )

    So essentially the choice was to disable the mysql extension ‘globally’ as opposed to per instance.

    I’m not an expert here (looking for reasoning so I can attempt intelligent decision making in the future..) just wanted to understand the justification.

    Thanks so much.. by the way this indeed solved my issue.

    Thanks in advance,
    giz

    1. My reason is because I’m using EHCP (easy hosting control panel) which has script to check php.ini for mysql.so extension. If there is no mysql.so in php.ini, the EHCP script will say no MySQL is running. If you don’t use EHCP, you can disable the php.ini record and keep the one in conf.d.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.