一、下载相应tgz包;
http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz
二、安装开始
解压
# tar zxvf PDO_MYSQL-1.0.2.tgz
# cd PDO_MYSQL-1.0.2
运行命令
# /usr/local/php/bin/phpize
Configuring for:
PHP Api Version: 20121212
Zend Module Api No: 20060613
Zend Extension Api No: 220060519
如果运行/usr/local/php/bin/phpize 出现Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script. 那么说明没有autoconf
那么执行命令 yum install m4
yum install autoconf
配置
./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql
如果配置
如果执行时报错
configure: warning: You will need re2c 0.12.0 or later if you want to regenerate PHP parsers.
checking for gawk... gawk
checking for MySQL support for PDO... yes, shared
checking for mysql_config... not found
configure: error: Cannot find MySQL header files under
解决办法:
cp /usr/local/mysql/bin/mysql_config /usr/bin
编译
如果执行时报错
/PDO_MYSQL-1.0.2/php_pdo_mysql_int.h:25:19: error: mysql.h: No such file or directory
In file included from /software/PDO_MYSQL-1.0.2/pdo_mysql.c:31:
/PDO_MYSQL-1.0.2/php_pdo_mysql_int.h:36: error: expected specifier-qualifier-list before ‘MYSQL‘
/PDO_MYSQL-1.0.2/php_pdo_mysql_int.h:48: error: expected specifier-qualifier-list before ‘MYSQL_FIELD‘
/PDO_MYSQL-1.0.2/php_pdo_mysql_int.h:53: error: expected specifier-qualifier-list before ‘MYSQL_RES‘
make: *** [pdo_mysql.lo] Error 1
解决办法:
yum install mysql-devel
如果执行yum install mysql-devel错误仍然存在,那么执行如下操作
这是因为在编译时需要mysql的头的文件,而它按默认搜索找不到头文件的位置,所以才出现这个问题.所以要将 /usr/local/mysql/include/ 目录下的mysql头文件链接到 /usr/local/include/ 的目录下:
ln -s /usr/local/mysql/include/* /usr/local/include/
一般来说,执行完上面的命令后,应该能编译过去 。然后再make和make install,pdo_mysql模块加进去了
三、修改php.ini;
extension_dir = "/usr/local/php/lib/php/extensions/no-debug-zts-20121212/"(no-debug-zts-20121212 该路径名根据自己的实际情况设置)
extension = "pdo_mysql.so"
自此,PDO_MYSQL安装完成。
http://blog.csdn.net/blueg2013/article/details/9307767