centos 下php7扩展pdo_mysql编译安装教程

23 篇文章 0 订阅
4 篇文章 0 订阅


linux下的php扩展与windows下的扩展安装有些不同。下面就拿在linux下扩展php的pdo,pdo_mysql模块来说明一下

由于php7默认去掉了mysql扩展,那么我们自己动手。

1.在php的原码安装包里,进入到etc/pdo_mysql里。假设你的php是安装在/usr/local/php里的。执行/usr/local/php/bin/phpize

2. 进行编译。./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql (假设你的mysql是安装在/usr/local/mysql)

3.编译安装。make,make install。

4.到了第3步的时候。在/usr/local/php/lib/php/extensions里就会多了个no-debug-non-zts-20050922(类似名称)文件夹,它里面就生成了一个pdo_mysql.so

5.修改php.ini,加入扩展语句extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20050922(类似名称)/pdo_mysql.so"

6.重启apache/nginx。OK扩展完成

7.安装pdo的方法与pdo_mysql的方法一样.但是要注意在这个安装过程中如果系统没有aclocal命令,那么请先安装这个命令,这个命令在autoconf包里。



./configure 的时候可能遇到的问题

[root@localhost pdo_mysql]# ./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql/ --with-zlib-dir=/usr/local/lib
checking for egrep... grep -E
checking for a sed that does not truncate output... /bin/sed
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
checking whether gcc and cc understand -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking for PHP prefix... /usr/local/php
checking for PHP includes... -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib
checking for PHP extension directory... /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613
checking for PHP installed headers prefix... /usr/local/php/include/php
checking for re2c... re2c
checking for re2c version... 0.12.3 (ok)
checking for gawk... gawk
checking for MySQL support for PDO... yes, shared
checking for the location of libz... /usr/local/lib
checking for mysql_config... /usr/local/mysql//bin/mysql_config
checking for mysql_query in -lmysqlclient... no
checking for mysql_query in -lmysqlclient... (cached) no
configure: error: PDO_MYSQL configure failed. Please check config.log for more information.


解决方法:

1、用php官方的mysqlnd。--with-pdo-mysql=mysqlnd ,php 5.3+版本都可以。

2、 checking for mysql_query in -lmysqlclient... no
              checking for mysql_query in -lmysqlclient... (cached) no


              先安装mysqlclient 就好了.


make && make install 遇到的问题

ext/mysqlnd/mysqlnd.h:没有那个文件或目录
 #include "ext/mysqlnd/mysqlnd.h"

解决方法:

  1、自己查看mysqlnd是否存在,不存在可能是缺mysql的开发包, 装一下  *mysql*-dev,  *mysql*-devel 之类的试一下

 2、如果有文件,根据错误找到相应的位置,然后修改路径ext/mysqlnd/mysqlnd.h ,我的是退后了两级../../ext/mysqlnd/mysqlnd.h    (根据自己文件位置确定)



评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

IT小智

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值