1. 进入PHP源码包ext/pdo目录
#cd /usr/local/zip/php5/ext/pdo
2. 执行/usr/local/php/bin/phpize 生成配置文件
3. 配置扩展pdo
./configure –with-php-config=/usr/local/php/bin/php-config –enable-pdo=shared
4. 编译 && 安装pdo
make && make install
成功则出现
Installing shared extensions: /usr/local/php//lib/php/extensions/no-debug-non-zts-20131226/
Installing header files: /usr/local/php//include/php/
Installing PDO headers: /usr/local/php//include/php/ext/pdo/
说明在/usr/local/php//lib/php/extensions/no-debug-non-zts-20131226/目录下生成了pdo.so文件.
5.进入PHP源码包ext/pdo_mysql目录
#cd /usr/local/zip/php5/ext/pdo_mysql
6.继续执行/usr/local/php/bin/phpize生成配置文件
7. 配置pdo_mysql:
./configure –with-php-config=/usr/local/php/bin/php-config –with-pdo-mysql=/usr/local/mysql
8. 编译 安装pdo_mysql
make && make install
成功则出现
Installing shared extensions: /usr/local/php//lib/php/extensions/no-debug-non-zts-20131226/
至此在此目录下已分别生成pdo.so文件和pdo_mysql.so文件.
9. 切换至php配置文件:
#cd /usr/local/php/lib
# vim php.ini 加入以下两句
extension=”/usr/local/php//lib/php/extensions/no-debug-non-zts-20131226/pdo_mysql.so”;
extension=”/usr/local/php//lib/php/extensions/no-debug-non-zts-20131226/pdo.so”;
重启php-fpm即可生效,至此已成功开启php的pdo扩展。
博主在开启时遇到的问题:
重启php-fpm时报错: [10-Sep-2018 14:21:15] NOTICE: PHP message: PHP Warning: PHP Startup: Invalid library (maybe not a PHP library) ‘/usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/pdo.so’ in Unknown on line 0
解决办法:extension_dir=/usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/ 解决。