22

After upgrading php from 5.1 to 5.2.10, I got the following warnings when php -v:

    # php -v
    PHP Warning:  PHP Startup: fileinfo: Unable to initialize module
    Module compiled with module API=20050922, debug=0, thread-safety=0
    PHP    compiled with module API=20060613, debug=0, thread-safety=0
    These options need to match
     in Unknown on line 0
    PHP Warning:  PHP Startup: mcrypt: Unable to initialize module
    Module compiled with module API=20050922, debug=0, thread-safety=0
    PHP    compiled with module API=20060613, debug=0, thread-safety=0
    These options need to match
     in Unknown on line 0
    PHP Warning:  PHP Startup: memcache: Unable to initialize module
    Module compiled with module API=20050922, debug=0, thread-safety=0
    PHP    compiled with module API=20060613, debug=0, thread-safety=0
    These options need to match
     in Unknown on line 0
    PHP Warning:  PHP Startup: mhash: Unable to initialize module
    Module compiled with module API=20050922, debug=0, thread-safety=0
    PHP    compiled with module API=20060613, debug=0, thread-safety=0
    These options need to match
     in Unknown on line 0
    PHP Warning:  PHP Startup: mssql: Unable to initialize module
    Module compiled with module API=20050922, debug=0, thread-safety=0
    PHP    compiled with module API=20060613, debug=0, thread-safety=0
    These options need to match
     in Unknown on line 0
    PHP Warning:  PHP Startup: readline: Unable to initialize module
    Module compiled with module API=20050922, debug=0, thread-safety=0
    PHP    compiled with module API=20060613, debug=0, thread-safety=0
    These options need to match
     in Unknown on line 0
    PHP Warning:  PHP Startup: tidy: Unable to initialize module
    Module compiled with module API=20050922, debug=0, thread-safety=0
    PHP    compiled with module API=20060613, debug=0, thread-safety=0
    These options need to match
     in Unknown on line 0
    PHP 5.2.10 (cli) (built: Nov 13 2009 11:24:03)
    Copyright (c) 1997-2009 The PHP Group
    Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies

How can I fix it? Thanks!

0

9 Answers 9

23

Looks like you haven't upgraded PHP modules, they are not compatible.

Check extension_dir directive in your php.ini. It should point to folder with 5.2 modules.

Create and open a phpinfo file and search for extension_dir to find the path.

Since you did upgrade, there is a chance that you are using old php.ini that is pointing to 5.1 modules

11
  • extension_dir points to /user/lib/php/modules in which there are many .so files. how can I tell the version of those .so files? thx
    – ohho
    Jun 28, 2010 at 9:08
  • When you run php as you did in question, for each incompatible module you will receive warning message: Unable to initialize module Module compiled with module API=20050922 In your case incompatible modules are: fileinfo, mcrypt, memcache, mhash, mssql, readline and tidy, so try to disable them and see does it make a difference.
    – bas
    Jun 28, 2010 at 20:54
  • @Horace: If you're on a Unix-like host, try this in the extension dir: strings -f *.so|grep API. There may be multiple 'API' strings in each .so, but should only be on with the API version number
    – Marc B
    Jun 28, 2010 at 21:06
  • 1
    @Marc, that won't work, at least it didn't on OSX when I tried :)
    – bas
    Jun 28, 2010 at 22:00
  • @bas: hmm. no strings command? grep didn't work? Maybe OSX PHP doesn't include the API version inside the .so file. Could be in the file's metadata (resource fork, extended attributes, whatever it's called these days).
    – Marc B
    Jun 28, 2010 at 22:18
14

try to upgrade each of those modules using pecl command

# pecl upgrade fileinfo
# pecl upgrade memcache
# pecl upgrade mhash
# pecl upgrade readline

etc...

1
  • by localhost wamp, how can i upgrade in windows?
    – Gem
    Oct 23, 2018 at 12:33
10

brew reinstall php56-mcrypt --build-from-source

Do this—pass the --build-from-source flag—for each module which needs to be compiled with the same version.

It may also require PHP options depending on your plugins. If so, brew reinstall php56 --with-thread-safety

To see all of the options for php[version] run brew options php56 (replacing 56 with your version)

2

Erase the module that can't be initialized and reinstall it.

1

This is an old thread, but I stumbled across it when trying to solve a similar problem.

For me, I got this particular error relating to the php_wincache.dll. I was in the process of updating PHP from 5.5.38 to 5.6.31 on a Windows server. For some reason, not all of the DLL files updated with the newest versions. Most did, but some didn't.

So, if you get an error similar to this, make sure all the extensions are in place and updated.

0

This is just describing why I had this issue in case someone finds it helpful.

My problem was that I had upgraded php with homebrew and had forced at some point the variable PHP_INI_SCAN_DIR in my profile or bashrc file so it was pointing to the old php version. Removed that line and fixed.

0

This happened to me when I tried to install a newer version of PHP. After finding that I also would need to reconfigure Apache for that I switched back to the old PHP version. Here the solution which worked for me:

change the httpd.conf to the correct versions:

 PHPIniDir ...
 LoadModule php5_module ...

Changed the

PATH - Environment Variable

When that does not take any effect

rename or delete the new PHP(-Version)-Folder

For some reason the last step did the trick for me. Even after a restart it did not have an effect before doing this.

0

If you installed php with homebrew, then check if your apache2.conf file is using homebrew version of php5.so file.

0
0

In my case, with Windows Server 2008, I had to change the PATH variable. The former version of PHP (VC9) was inside it.

I have changed it with the newer version of PHP (VC11).

After a restart of Apache, it was okay.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.