大家安装PHP扩展一般步骤应该都是如下:
1、phpize
2、./configure --with-php-config=/usr/local/php/bin/php-config
3、make & make install
这样基本都是成了
然而这次我安装pdo_mysql的时候出现了版本不匹配的问题:
PHP Warning: PHP Startup: pdo_mysql: Unable to initialize module
Module compiled with module API=20151012
PHP compiled with module API=20160303
意思是PHP编译版本号是20160303,而pdo_mysql模块编译版本是20151012,不匹配。
我的错误
Stopping php-fpm: [ OK ]
Starting php-fpm: [22-Feb-2018 16:46:24] NOTICE: PHP message: PHP Warning: PHP Startup: gd: Unable to initialize module
Module compiled with module API=20151012
PHP compiled with module API=20160303
These options need to match
in Unknown on line 0
我这边是安装gd扩展。通过 find / -name phpize找到phpize的目录,手贱把这些目录全部删除了
再用phpize会提示 command not found
就 yum remove php71w-* 删除所有,重装一遍php7
[root@iZ2ze9lk5j1zbi3qi14shwZ gd]# phpize
Can't find PHP headers in /usr/include/php
The php-devel package is required for use of this command.
这是没安装php-devel包
安装下php71w对应的包即可
yum install php71w-devel
再次在源码gd库中phpize中就会提示是20160303了
[root@iZ2ze9lk5j1zbi3qi14shwZ gd]# phpize
Configuring for:
PHP Api Version: 20160303
Zend Module Api No: 20160303
Zend Extension Api No: 320160303
重启后依然是那鸟样,什么鬼
[root@iZ2ze9lk5j1zbi3qi14shwZ gd]# /etc/init.d/php-fpm restart
Stopping php-fpm: [ OK ]
Starting php-fpm: [22-Feb-2018 17:11:34] NOTICE: PHP message: PHP Warning: PHP Startup: gd: Unable to initialize module
Module compiled with module API=20151012
PHP compiled with module API=20160303
These options need to match
in Unknown on line 0
找到php-config文件所在目录
find / -name php-config
进去看看php-config版本,如果不是7.1版本的,全删除,只留一个7.1版本的
/usr/local/php/bin/php-config
rm -rf /usr/local/php/bin/php-config
rm -rf /usr/local/bin/php-config
再来一遍
phpize
./configure
make&&make install
还是没用
删除已存在的gd.so扩展,再来一遍依然没用
rm -rf /usr/lib64/php/modules/
把源码解压的全部删除,再解压一份,然后再来一遍
还是不行,最后……额……
不用源码安装了,
yum install php71w-gd
/etc/init.d/php-fpm restart
好了