不需要重新编译php,可以动态扩展php模块
这里以扩展mysqli为例:
1.安装phpize需要的依赖包
# yum install m4 autoconf
2.生成编译mysqli的configure
进入PHP源码目录中扩展模块目录ext
# cd /app/httpd/php-5.6.34/ext/mysqli
#/usr/local/php/bin/phpize
Configuring for:
PHP Api Version: 20131106
Zend Module Api No: 20131226
Zend Extension Api No: 220131226
3.查下当前PHP的扩展目录
# /usr/local/php/bin/php-config --extension-dir
/usr/local/php-5.6.34/lib/php/extensions/no-debug-non-zts-20131226
4.编译mysqli
# ./configure --with-php-config=/usr/local/php/bin/php-config --with-mysqli=/usr/local/mysql/bin/mysql_config
#make && make install clean
Installing shared extensions: /usr/local/php-5.6.34/lib/php/extensions/no-debug-non-zts-20131226/
Installing header files: /usr/local/php-5.6.34/include/php/
5.检查
#ll /usr/local/php-5.6.34/lib/php/extensions/no-debug-non-zts-20131226/
-rwxr-xr-x 1 root root 715322 Mar 5 16:11 mysqli.so
6.添加启用mysqli
#vim /etc/php.ini
找到[MySQLi]配置块
添加
extension=mysqli.so
7.重启php
原文地址:http://blog.51cto.com/191226139/2083108
时间: 2024-10-16 23:32:11