Apache 是“无法初始化模块”,因为在更改 PHP 配置后模块和 PHP 的 API 不匹配
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2394532/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Apache is "Unable to initialize module" because of module's and PHP's API don't match after changing the PHP configuration
提问by soshial
php -v gives this
php -v 给出了这个
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.
附:我已经从 php 5.2 升级到 5.3。在此之前一切正常。
采纳答案by Pascal MARTIN
When you update the version of PHP (especially when going from version X.Y to version X.Z), you must update the PHP extensionsas well.
当您更新 PHP 版本时(尤其是从 XY 版本升级到 XZ 版本时),您也必须更新 PHP 扩展。
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.
这是因为 PHP 扩展是用 C 开发的,并且“接近”PHP 的内部结构——这意味着,如果这些内部结构的 API 发生变化,则必须重新编译扩展以使用新版本。
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.
而且,在 PHP 5.2 和 PHP 5.3 之间,据我所知,PHP 引擎使用的内部数据结构发生了一些修改——这意味着必须重新编译扩展,以匹配那些新版本数据结构。
How to update your PHP extensions will depend on which system you are using.
如何更新您的 PHP 扩展取决于您使用的系统。
If you are on windows, you can find the .dllfor 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.
如果你在windows上,你可以在.dll这里找到一些扩展:http: //downloads.php.net/pierre/
关于不同版本的更多信息,你可以看看windows左侧边栏上的内容.php.net。
If you are on Linux, you must either :
如果您使用的是 Linux,则必须:
- Check what your distribution provides
- Or use the
peclcommand, to re-download the sources of the extensions in question, and re-compile them.
- 检查您的发行版提供了什么
- 或者使用
pecl命令,重新下载有问题的扩展的源代码,并重新编译它们。
回答by B?o Nam
just
只是
pecl uninstall module_name
then
然后
pecl install module_name
回答by Vladimir Lazarevski
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:
您的问题出在 php5-dev 包中。我猜你从较旧的 linux 版本上的 php5.2 转到了 php5.3。我做了同样的事情,当我设法安装 php 5.3 时,与 php5-dev 发生了冲突。出于某种原因,它没有升级到新版本。不知道为什么会这样,我不在乎,但是这会使您的扩展使用较旧的 API 版本编译,而 php ofc 使用较新的 api 版本。我为解决这个问题所做的是:
I removed php5-dev with
sudo apt-get remove php5-dev, then I ran sudo apt-get autoremoveto 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.
我用 删除了 php5-dev
sudo apt-get remove php5-dev,然后我跑去sudo apt-get autoremove摆脱给我带来麻烦的剩菜,之后我又重新安装了 php5-dev。
sudo apt-get install php5-dev.
Once that was done, I removed my memcache with sudo pecl uninstall memcacheand 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 :)
完成后,我删除了我的 memcachesudo pecl uninstall memcache并重新安装了它sudo pecl install memcache。现在模块和 php 都有相同的 api 版本,所以我马上知道我已经解决了问题:)
Hope it helps.
希望能帮助到你。
回答by apkostka
It's possible that the modules are installed, but your PHP.ini still points to an old directory.
模块可能已安装,但您的 PHP.ini 仍指向旧目录。
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:
检查 /usr/lib/php/extensions 的内容。在我的,有两个目录:no-debug-non-zts-20060613 和 no-debug-non-zts-20060613。在 php.ini 的第 428 行左右,更改:
extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20060613"
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"
extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20090626"
Then restart apache. This should resolve the issue.
然后重启apache。这应该可以解决问题。
回答by Andrew
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-configtool.
我在这个问题上挣扎了很长时间,发现当你运行 configure 时,只需将路径传递给正确的php-config工具。
In my case, it was
就我而言,它是
./configure --with-php-config=/usr/local/zend/bin/php-config
... If you're unsure, run a locate php-configon your machine and find the right one amongst the different versions installed.
... 如果您不确定,请locate php-config在您的机器上运行一个并在安装的不同版本中找到正确的一个。
Hope this helps somebody in the future.
希望这对将来的人有所帮助。
PS. My default php-configwas set to 20090926 which is PHP 5.3. The one I manually entered as a param for ./configure wasfor PHP 5.4 (2010...)
附注。我的默认php-config设置为 20090926,即 PHP 5.3。我手动输入的一个参数./configure was作为 PHP 5.4 (2010 ...)
回答by vicky shrestha
I had this part enabled in my php.ini
我在我的 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
评论这些行后,composer 已安装在我的 Windows 10 中
回答by Goke Obasa
I had a similar issue after upgrading from PHP 5.5 to PHP 5.6. The phpizeand php-configlibraries being used to compile the phalcon extension were still the ones from PHP 5.5. I had to run the command below:
从 PHP 5.5 升级到 PHP 5.6 后,我遇到了类似的问题。用于编译 phalcon 扩展的phpize和php-config库仍然是 PHP 5.5 中的库。我必须运行以下命令:
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.
我希望这可以帮助别人。
回答by YouCL
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/phpizeand /etc/alternatives/php-configto /usr/local/php/bin/phpizeand /usr/local/php/bin/php-config.
Hopes this is helpful.
就我而言,我使用 lnmp 安装了 5.4.45 版本的 php。但也许是因为我在 lnmp 之后安装了 php5-dev(如果你安装了 lnmp,我猜这不是必需的),我的 phpize 和 php-config 都指向比 php 更旧的版本工具。
我解决了这个由变化的软链接/etc/alternatives/phpize,并/etc/alternatives/php-config以/usr/local/php/bin/phpize和/usr/local/php/bin/php-config。
希望这是有帮助的。
回答by user2289259
回答by xsor
In my case in php.ini
在我的情况下在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:
我删除了支持不同 PHP 版本的 Codelobster,所以需要更新到:
[CLDbg]
;extension=php_cl_dbg_5_3_VC9.dll
;clport=6000

