2013-10-01 11:56:01
来 源
中存储网
MySQL
这里分享一下PHP5.4安装pdo_MySQL出错的解决办法,希望对于初学Apache服务器相关的朋友有帮助,更多Apache安装、配置、报错处理等资源请本站内搜索。
今天给新的测试机安装lamp环境,但php要求5.4,mysql是5.5,apache是2.2,这样一来我就只能手动安装了,最后居然让php5.4整得我差点无法使这个环境正常运行了,因为大家都知道安装了php,必然要安装pdo_mysql,罪魁祸首就是这个pdo_mysql,下面我来说说怎么解决的.

   系统:centos 5.5

   需要的软件:httpd-2.2.22.tar.gz

php-5.4.11.tar.gz

mysql-5.5.22.tar.gz

PDO_MYSQL-1.0.2.tgz

libiconv-1.14.tar.gz

1.安装前准备

yum -y install gcc  gcc-c++ libtool-libs autoconf /

freetype-devel gd libjpeg-devel  libpng-devel libxml2-devel /

ncurses-devel zlib-devel zip unzip curl-devel wget crontabs /

file bison cmake patch mlocate flex diffutils automake make /

kernel-devel cpp readline-devel openssl-devel vim-minimal /

glibc-devel  glib2-devel bzip2-devel e2fsprogs-devel libidn-devel /

gettext-devel expat-devel libcap-devel  libtool-ltdl-devel pam-devel /

pcre-devel libmcrypt-devel

2.搭建lamp环境

这个就不说了,网上这样的文章太多了.

3.安装PDO_MYSQL

wget http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz

tar zxf PDO_MYSQL-1.0.2.tgz && cd PDO_MYSQL-1.0.2

/usr/local/php/bin/phpize

./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql

make

在make的时候有可能会出现下面的错误:

In file included from /data1/PDO_MYSQL-1.0.2/pdo_mysql.c:31:

/data1/PDO_MYSQL-1.0.2/php_pdo_mysql_int.h:25:19: error: mysql.h: No such file or directory

In file included from /data1/PDO_MYSQL-1.0.2/pdo_mysql.c:31:

/data1/PDO_MYSQL-1.0.2/php_pdo_mysql_int.h:36: error: expected specifier-qualifier-list before ‘MYSQL’

/data1/PDO_MYSQL-1.0.2/php_pdo_mysql_int.h:48: error: expected specifier-qualifier-list before ‘MYSQL_FIELD’

/data1/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

解决办法:

这是因为在编译时需要mysql的头的文件,而它按默认搜索找不到头文件的位置,所以才出现这个问题.所以要将 /usr/local/mysql/include/ 目录下的mysql头文件链接到 /usr/local/include/ 的目录下:

ln -s /usr/local/mysql/include/* /usr/local/include/

然后再make和make install,pdo_mysql模块加进去了.

声明: 此文观点不代表本站立场;转载须要保留原文链接;版权疑问请联系我们。