[apache] Apache is "Unable to initialize module" because of module's and PHP's API don't match after changing the PHP configuration

php -v gives this

PHP Warning:  PHP Startup: memcache: Unable to initialize module
Module compiled with module API=20060613
PHP    compiled with module API=20090626
These options need to match in Unknown on line 0
PHP Warning:  PHP Startup: memcache: Unable to initialize module
Module compiled with module API=20060613
PHP    compiled with module API=20090626
These options need to match in Unknown on line 0
bogus test name tests/

ps. i've upgraded from php 5.2 to 5.3. before this everything worked okay.

This question is related to apache memcached php

The answer is


When you update the version of PHP (especially when going from version X.Y to version X.Z), you must update the PHP extensions as well.


This is because PHP extensions are developped in C, and are "close" to the internals of PHP -- which means that, if the APIs of those internals change, the extension must be re-compiled, to use the new versions.

And, between PHP 5.2 and PHP 5.3, for what I remember, there have been some modifications in the internal data-structures used by the PHP engine -- which means extensions must be re-compiled, in order to match that new version of those data-structures.


How to update your PHP extensions will depend on which system you are using.

If you are on windows, you can find the .dll for some extensions here : http://downloads.php.net/pierre/
For more informations about the different versions, you can take a look at what's said on the left-sidebar of windows.php.net.

If you are on Linux, you must either :

  • Check what your distribution provides
  • Or use the pecl command, to re-download the sources of the extensions in question, and re-compile them.

just

pecl uninstall module_name

then

pecl install module_name

In my case, I used lnmp to install php with version 5.4.45. But maybe because I installed php5-dev after lnmp (which I guess is not necessary if you installed lnmp), my phpize and php-config both point to older version tools than php.
I solved this by change the soft link of /etc/alternatives/phpize and /etc/alternatives/php-config to /usr/local/php/bin/phpize and /usr/local/php/bin/php-config.
Hopes this is helpful.


Here is the one that works with php 5.5. Download xampp 1.8.3 from here and download memcache dll from here


Before you phpize, make sure to update your path ($PS1) to point to the new PHP! phpize uses your environment, and if you still have vestiges of your old PHP in your path or other parts of the environment, things will get hairy!


This problem has just happened to me and has been solved simply by increasing memory_limit from 32 M to 64 M You can adjust the value on the file where php.ini exists

locate php.ini then choose the right file and search for memory_limit and after modifying it you must reboot the apache /etc/init.d/httpd restart

All the best.


In my case in php.ini

[CLDbg]
extension=php_cl_dbg_5_3_VC9.dll
clport=6000

I removed Codelobster which support different PHP version, so need to update to:

[CLDbg]
;extension=php_cl_dbg_5_3_VC9.dll
;clport=6000

I had a similar issue after upgrading from PHP 5.5 to PHP 5.6. The phpize and php-config libraries being used to compile the phalcon extension were still the ones from PHP 5.5. I had to run the command below:

sudo apt-get install php5.6-dev

There will be a long stacktrace, the key information I saw was this:

update-alternatives: using /usr/bin/php-config5.6 to provide /usr/bin/php-config (php-config) in auto mode
update-alternatives: using /usr/bin/phpize5.6 to provide /usr/bin/phpize (phpize) in auto mode

I hope this helps someone.


It's possible that the modules are installed, but your PHP.ini still points to an old directory.

Check the contents of /usr/lib/php/extensions. In mine, there were two directories: no-debug-non-zts-20060613 and no-debug-non-zts-20060613. Around line 428 of your php.ini, change:

extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20060613"

to

extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20090626"

Then restart apache. This should resolve the issue.


I'd the same error even after recompiling the modules.

But I solved it you just have to specify the absolute path of your phpize.


I struggled with this issue for a long time and found out that when you run configure, just pass it the path to the correct php-config tool.

In my case, it was

./configure --with-php-config=/usr/local/zend/bin/php-config 

... If you're unsure, run a locate php-config on your machine and find the right one amongst the different versions installed.

Hope this helps somebody in the future.

PS. My default php-config was set to 20090926 which is PHP 5.3. The one I manually entered as a param for ./configure was for PHP 5.4 (2010...)


What worked for me was simply to do the following:

open the php.ini file.

Under the DYNAMIC EXTENSIONS heading, comment out the following line as

;extension=php_java.dll

Restarted Apache and all was fine


I had this part enabled in my php.ini

 extension=php_memcache.dll
    [Memcache]
    memcache.allow_failover = 1
    memcache.max_failover_attempts=20
    memcache.chunk_size =8192
    memcache.default_port = 11211

After commenting these lines composer was installed in my windows 10


Your problem is within the php5-dev package. I guess you went from php5.2 on an older linux version to php5.3. I did the same thing, and when I managed to install php 5.3 there was a conflict with php5-dev. For some reason it doesn't get upgraded to the new version. Dunno why is that and I don't care, however this makes your extension compiled with the older API version, while php ofc is with the newer api version. What I did to solve this problem was:

I removed php5-dev with sudo apt-get remove php5-dev, then I ran sudo apt-get autoremove to get rid of the leftovers that were giving me the trouble, and after that I just installed php5-dev again. sudo apt-get install php5-dev.

Once that was done, I removed my memcache with sudo pecl uninstall memcache and installed it again sudo pecl install memcache. Now both the module and the php had the same api version so I knew right away that I had the issue solved :)

Hope it helps.


Examples related to apache

Enable PHP Apache2 Switch php versions on commandline ubuntu 16.04 Laravel: PDOException: could not find driver How to deploy a React App on Apache web server Apache POI error loading XSSFWorkbook class How to enable directory listing in apache web server Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details How to enable php7 module in apache? java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient The program can't start because api-ms-win-crt-runtime-l1-1-0.dll is missing while starting Apache server on my computer

Examples related to memcached

Curl command without using cache get all keys set in memcached Memcached vs. Redis? configure: error: C compiler cannot create executables How to stop and restart memcached server? PHP memcached Fatal error: Class 'Memcache' not found Apache is "Unable to initialize module" because of module's and PHP's API don't match after changing the PHP configuration Memcache Vs. Memcached When should I use Memcache instead of Memcached? Good examples of python-memcache (memcached) being used in Python?

Examples related to php

I am receiving warning in Facebook Application using PHP SDK Pass PDO prepared statement to variables Parse error: syntax error, unexpected [ Preg_match backtrack error Removing "http://" from a string How do I hide the PHP explode delimiter from submitted form results? Problems with installation of Google App Engine SDK for php in OS X Laravel 4 with Sentry 2 add user to a group on Registration php & mysql query not echoing in html with tags? How do I show a message in the foreach loop?