我正在尝试在RHEL5机器上安装freetds和php-mssql。我已经成功地完成了(看起来)所有的事情。然而,当PHP试图加载模块时,我得到了以下错误:
PHP Warning: PHP Startup: mssql: Unable to initialize module
Module compiled with module API=20090626, debug=0, thread-safety=0
PHP compiled with module API=20050922, debug=0, thread-safety=0
These options need to match我一直在绞尽脑汁,试图弄清楚为什么它们是不同的价值观,但没有成功。
在最近的一次尝试中,我下载了我正在运行的版本( php -5.3.8)的php源代码,进入ext/mssql文件夹并运行phpize,configure,make,make install。
我验证了mssql.so文件是否在适当的文件夹中,以及php是否正在尝试加载它。
phpize -v
Configuring for:
PHP Api Version: 20050922
Zend Module Api No: 20090626
Zend Extension Api No: 220090626发布于 2011-12-07 06:35:51
RHEL有一个较旧的php版本(5.1.x),而安装较新的php版本(如5.3.x)意味着一些变化。如果你从非官方的repos安装,你会看到名为php-*和php5-*的包。同时拥有两个版本可能是问题的根源。
看起来你的系统正在访问以前安装的php的一些配置文件。
查看一下:- /etc/php.d确保您没有旧版本中的元素-查看一下/usr/bin/ php-config *,如果您同时拥有php-config和php-config5,请删除(重命名) /usr/bin/php-config并创建一个指向新版本的符号链接:
# mv /usr/bin/php-config /usr/bin/php-config_old
# ln -s /usr/bin/php-config5 /usr/bin/php-config希望这能有所帮助
发布于 2011-12-07 07:21:12
我可以确认,当一个模块因为一个不同的API而不能加载时,那是因为一个旧的php-config。然后,您必须查看/usr/bin/php-config并用较新的版本覆盖它。
发布于 2021-05-20 10:10:41
对于那些使用基于debian的发行版的用户,例如Ubuntu,如果您安装了多个版本的php,您还可以检查是否有任何已设置的替代版本。
要快速确定已为与php相关的任何内容设置了哪些替代方案,一种方法是使用ls -l /etc/alternatives/*php*
输出示例:
$ ls -l /etc/alternatives/*php*
lrwxrwxrwx 1 root root 15 May 19 00:02 /etc/alternatives/php -> /usr/bin/php7.4
lrwxrwxrwx 1 root root 19 Jan 28 18:50 /etc/alternatives/php-cgi -> /usr/bin/php-cgi7.4
lrwxrwxrwx 1 root root 23 Jan 28 18:50 /etc/alternatives/php-cgi-bin -> /usr/lib/cgi-bin/php7.4
lrwxrwxrwx 1 root root 35 Jan 28 18:50 /etc/alternatives/php-cgi.1.gz -> /usr/share/man/man1/php-cgi7.4.1.gz
lrwxrwxrwx 1 root root 22 May 19 20:27 /etc/alternatives/php-config -> /usr/bin/php-config7.4
lrwxrwxrwx 1 root root 38 May 19 20:27 /etc/alternatives/php-config.1.gz -> /usr/share/man/man1/php-config7.4.1.gz
lrwxrwxrwx 1 root root 24 May 19 20:30 /etc/alternatives/php-fpm.sock -> /run/php/php8.0-fpm.sock
lrwxrwxrwx 1 root root 31 May 19 00:02 /etc/alternatives/php.1.gz -> /usr/share/man/man1/php7.4.1.gz
lrwxrwxrwx 1 root root 18 May 19 20:29 /etc/alternatives/phpdbg -> /usr/bin/phpdbg7.4
lrwxrwxrwx 1 root root 34 May 19 20:29 /etc/alternatives/phpdbg.1.gz -> /usr/share/man/man1/phpdbg7.4.1.gz
lrwxrwxrwx 1 root root 18 May 19 20:29 /etc/alternatives/phpize -> /usr/bin/phpize7.4
lrwxrwxrwx 1 root root 34 May 19 20:29 /etc/alternatives/phpize.1.gz -> /usr/share/man/man1/phpize7.4.1.gz在我的例子中,我是在安装了7.4之后才安装php8的。然后我需要切换回来,我的一半选择仍然设置为8。当我试图启用我用pecl安装的扩展时,我遇到了OP提到的问题。
因此,例如,当从php8.0切换回7.4时,如果其中一个替代方案的符号链接仍然指向8.0,比如php-fpm.sock,那么您将
sudo update-alternatives --config php-fpm.sock并选择选项的编号匹配php7.4-fpm.sock (在下面的示例中为1)
$ sudo update-alternatives --config php-fpm.sock
There are 2 choices for the alternative php-fpm.sock (providing /run/php/php-fpm.sock).
Selection Path Priority Status
------------------------------------------------------------
* 0 /run/php/php8.0-fpm.sock 80 auto mode
1 /run/php/php7.4-fpm.sock 74 manual mode
2 /run/php/php8.0-fpm.sock 80 manual mode
Press <enter> to keep the current choice[*], or type selection number: 1https://stackoverflow.com/questions/8406743
复制相似问题