PHP 不加载 php.ini 中指定的扩展,而是使用 dl() 加载

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5368580/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 21:11:38  来源:igfitidea点击:

PHP doesn't load extensions specified in php.ini, but loads with dl()

php

提问by Nekuromento

Php doesn't load extensions specified through php.ini

Php 不加载通过 php.ini 指定的扩展

php -vdoesn't give any errors or warnings

php -v不给出任何错误或警告

php -i | grep extension_dirshows that extension_dir is set to where extension files are, but they don't show up in extension list in php -m

php -i | grep extension_dir显示 extension_dir 设置为扩展文件所在的位置,但它们没有显示在扩展列表中 php -m

However running php -r 'dl("apc.so"); phpinfo();' | grep apcshows that modules load normaly with dl()function.

但是运行php -r 'dl("apc.so"); phpinfo();' | grep apc显示模块正常加载dl()功能。

I installed php-5.3.5 from source. Configured with

我从源代码安装了 php-5.3.5。配置为

'--enable-fastcgi'
'--enable-fpm'
'--enable-mbstring'
'--enable-pdo'
'--enable-inline-optimization'
'--enable-sockets'
'--enable-zip'
'--enable-mbregex'
'--enable-xml'
'--enable-sysvsem'
'--enable-sysvshm'
'--enable-pcntl'
'--enable-ftp'
'--enable-soap'
'--enable-shmop'
'--disable-rpath'
'--disable-debug'
'--with-mcrypt'
'--with-zlib'
'--with-curl'
'--with-bz2'
'--with-mysql'
'--with-gettext'
'--with-gd'
'--with-pdo-mysql'
'--with-pcre-regex'
'--with-mhash'
'--with-pic'
'--with-zlib-dir'
'--with-ttf'
'--with-openssl'
'--with-png-dir'
'--with-libdir=lib64'
'--without-pdo-sqlite'
'--without-sqlite'

uname -aprints:

uname -a印刷:

Linux ip-*-*-*-* 2.6.34.7-56.40.amzn1.x86_64 #1 SMP Fri Oct 22 18:48:49 UTC 2010 x86_64 x86_64 x86_64 GNU/Linux

Php runs on nginx 0.9.5 through php-fpm

Php 通过 php-fpm 在 nginx 0.9.5 上运行

采纳答案by Nekuromento

Sort-of fixed this by statically linking extensions I needed in the php executable, everything works now. Server won't load xdebug extension though.

通过静态链接我在 php 可执行文件中需要的扩展来解决这个问题,现在一切正常。尽管服务器不会加载 xdebug 扩展。

回答by Pascal MARTIN

For extensions to be loaded, you must have one line such as the following one :

要加载扩展,您必须有一行,例如以下一行:

extension=apc.so

in the php.ini(or any other .inifile)file that's used by PHP.

在PHP 使用的php.ini(或任何其他.ini文件)文件中。


If extensions load properly when you're using dl(), it means your extensions are OK (no wrong version or anything like that).


如果在您使用时扩展加载正确dl(),则意味着您的扩展没问题(没有错误的版本或类似的东西)

The next step, so is to :

下一步是:

  • Make sure you have added the extension=...lines to your php.inifile
  • Make sure you've modified the right php.inifile
  • 确保您已将这些extension=...行添加到php.ini文件中
  • 确保您修改了正确的php.ini文件

You can check which php.inifile is used : it's displayed in the ouput of phpinfo().

您可以检查使用了哪个php.ini文件:它显示在phpinfo().


Note : with some Linux distributions, the php.inifile used in CLI is not the same one as the one used with Apache (not sure about the one used for nginx).


注意:对于某些 Linux 发行版,php.iniCLI 中使用的文件与 Apache 中使用的文件不同(不确定用于 nginx 的文件)

回答by Nikhil Kurkure

Go to Php.iniFile from phpmyadmin open in text editor and search for ;extension=php_soap.dlland just remove ;symbol and after that restartyour Wamp/xamp services and then refreshyour url page..enjoy

php.ini中从phpMyAdmin的文本编辑器中打开文件,然后搜索;延长= php_soap.dll,只是删除; 符号,然后重新启动您的 Wamp/xamp 服务,然后刷新您的 url 页面..享受