linux下 php 安装mysql的扩展模块
1.安装mysql-devel包
[root@DBproxy ~]# yum install mysql-devel
注:该包必须在编译php之前安装好,否则在安装php的mysql扩展模块是会碰到各种古怪问题
2. php的安装
#下载
[root@DBproxy zabbix]# wget http://119.90.25.34/cn2.php.net/distributions/php-5.6.28.tar.gz
#解压
[root@DBproxy zabbix]# tar -zxvf php-5.6.28.tar.gz
#安装
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql
make && make instal
#安装扩展模块
1.进入安装包中的扩展模块目录
[root@DBproxy ext]# pwd
/usr/local/src/php-5.6.28/ext
2.进入准备安装的模块目录
[root@DBproxy ext]# cd mysqli
[root@DBproxy mysqli]# pwd
/usr/local/src/php-5.6.28/ext/mysqli
3.执行phpize(必须在被安装模块的目录中)
[root@DBproxy mysqli]# /usr/local/php/bin/phpize
Configuring for:
PHP Api Version: 20131106
Zend Module Api No: 20131226
Zend Extension Api No: 220131226
[root@DBproxy mysqli]#
4.开始安装
[root@DBproxy mysqli]#./configure --with-php-config=/usr/local/php/bin/php-config
[root@DBproxy mysqli]#make
[root@DBproxy mysqli]#make install
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/
Installing header files: /usr/local/php/include/php/
[root@DBproxy mysqli]#
#模块被安装的目录
[root@DBproxy mysqli]# ls -l /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/
总用量 1724
-rwxr-xr-x. 1 root root 723693 11月 23 00:13 mysqli.so
-rwxr-xr-x. 1 root root 184403 11月 23 00:11 mysql.so
-rwxr-xr-x. 1 root root 586616 11月 23 00:10 opcache.so
-rwxr-xr-x. 1 root root 258143 11月 23 00:18 pdo_mysql.so
[root@DBproxy mysqli]#
5.将mysql.so添加到php.ini参数文件中(该文件的位置可在apache的http.conf中查到)
extension=pdo_mysql.so
extension=mysqli.so
注:不要在php.ini中添加extension=mysql.so,否则apache在启动时会报异常:
PHP Warning: PHP Startup: Invalid library (maybe not a PHP library) 'mysql.so' in Unknown on line 0。
通过phpinfo发现,即使不在php.ini中添加extension=mysql.so,php启动后默认是会加载mysql.so模块的
http://www.cnblogs.com/zhuque/archive/2012/11/03/2763351.html
http://www.banping.com/?p=864
http://www.linuxidc.com/Linux/2014-11/109911.htm
http://chen498402552-163-com.iteye.com/blog/1161254