php访问mysql接口pdo-mysql安装

php编译的时候加了这个--with-pdo-mysql=mysqlnd和--with-mysql=mysqlnd了,如果php编译时候加了就不用安装;如下说明已经安装了,有了,就不需要安装了,安装了也不会错误的,两个兼容的。

[root@web01 opcache]# /application/php/bin/php -i|grep configure

Configure Command =>  './configure'  '--prefix=/application/php5.5.32' '--with-mysql=/application/mysql/' '--with-pdo-mysql=mysqlnd' '--with-iconv-dir=/usr/local/libiconv' '--with-freetype-dir' '--with-jpeg-dir' '--with-png-dir' '--with-zlib' '--with-libxml-dir=/usr' '--enable-xml' '--disable-rpath' '--enable-bcmath' '--enable-shmop' '--enable-sysvsem' '--enable-inline-optimization' '--with-curl' '--enable-mbregex' '--enable-fpm' '--enable-mbstring' '--with-mcrypt' '--with-gd' '--enable-gd-native-ttf' '--with-openssl' '--with-mhash' '--enable-pcntl' '--enable-sockets' '--with-xmlrpc' '--enable-soap' '--enable-short-tags' '--enable-static' '--with-xsl' '--with-fpm-user=www' '--with-fpm-group=www' '--enable-ftp' '--enable-opcache=no'

PHP Warning:  Unknown: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in Unknown on line 0

[root@web01 opcache]#

手动安装也不冲突:安装如下:

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

tar xf PDO_MYSQL-1.0.2.tgz 

cd PDO_MYSQL-1.0.2/

/application/php/bin/phpize

./configure  --with-php-config=/application/php/bin/php-config --with-pdo-mysql=/application/mysql

make

make install

ll /application/php5.5.32/lib/php/extensions/no-debug-non-zts-20121212/

[root@web01 PDO_MYSQL-1.0.2]# make

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

In file included from /home/oldboy/tools/PDO_MYSQL-1.0.2/pdo_mysql.c:31:

/home/oldboy/tools/PDO_MYSQL-1.0.2/php_pdo_mysql_int.h:36: error: expected specifier-qualifier-list before 'MYSQL'

/home/oldboy/tools/PDO_MYSQL-1.0.2/php_pdo_mysql_int.h:48: error: expected specifier-qualifier-list before 'MYSQL_FIELD'

/home/oldboy/tools/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 的头的文件。而它按默认搜索找不到头文件的位置,所以才出现这个问题。通过软连接把MySQL头文件对应到/usr/local/include/下就好
比如你的MySQL安装文件位于/application/mysql,

,那么就执行以下命令:

[root@web01 PDO_MYSQL-1.0.2]# ln -s /application/mysql/include/* /usr/local/include/

[root@web01 PDO_MYSQL-1.0.2]# ll /application/php5.5.32/lib/php/extensions/no-debug-non-zts-20121212/

total 1624

-rwxr-xr-x 1 root root 258088 Mar  1 10:50 memcache.so

-rwxr-xr-x 1 root root 543497 Mar 18 18:41 opcache.so

-rwxr-xr-x 1 root root 158884 Mar 18 20:02 pdo_mysql.so

-rwxr-xr-x 1 root root 692884 Mar 18 18:19 xcache.so

原文地址:https://www.cnblogs.com/sandshell/p/8597185.html