由于现在官方主推PDO,已经没有mysql扩展了(PHP7)。
http://php.net/manual/zh/function.mysql-query.php
//官网上面也写明了。
现在,我的没有mysql_pdo的扩展。可以php -m可以看见。也可以phpinfo()看见。
总之现在没有mysql_pdo。
第一种方法,就是重新编译安装
make clean //清除上次编译安装的命令
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/httpd/bin/apxs --enable-mysqlnd --with-pdo-mysql=mysqlnd
make && make install
//如果出现了,下面的报错。
make: *** [ext/fileinfo/libmagic/apprentice.lo] Error 1
//这是由于内存小于1G所导致. Disable fileinfo support 禁用 fileinfo
//就是在加上--disable-fileinfo
//以后还是多玩虚拟机算了,买个4G内存,加个固态硬盘。那有这么多内存不足的问题。
//加上--disable-fileinfo之后,重新来一遍吧。
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/httpd/bin/apxs --enable-mysqlnd --with-pdo-mysql=mysqlnd --disable-fileinfo
//make && make install 之后去看结果吧
//php -m 或者重启apache去phpinfo看结果吧。
/usr/local/php/bin/php -m
//第一种方法完成。
然后就是我特么的不想重新编译。又慢时间又长,肿么办?
//放一张图片,效果,果然不同了。
第二种方法就是,继续看下面
你php7安装源码的路径里面有个ext的目录
/root/tools/php-7.0.11/ext 这个是我的
//里面的,你想扩展安装那个就是安装那个。先搞pdo_mysql
cd pdo_mysql //进去
//里面没有configure 的文件。就用phpize来扩展模块
/usr/local/php/bin/phpize //看看有没有comfigure
yum install autoconf -y //autoconf是一个用于生成可以自动的配置软件源代码包以适应多种UNIX系统的shell脚本的工具
./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql //有configure之后,写这个进去,这个是mysql安装在/usr/local/mysql的。
make && make install
echo 'extension="pdo_mysql.so"' >> /usr/local/php/lib/php.ini
//之后就是php -m ,看看有没有dpo_mysql
//其实我的阿里云没有这样搞,你们多去虚拟机搞吧。至少内存来个2G,再来个双核
//在搞一个openssl。用到composer需要openssl扩展。
cd openssl //去到openssl里面,没有configure
/usr/local/php/bin/phpize //来这个试试看,
Cannot find config.m4. //爆出这个句话,拿去翻译,就是没有找到config.m4
//学英文了,会看见文件夹里面有个config0.m4。 复制一个试试看
cp config0.m4 config.m4 //多重影分身术,好了,多了个config.m4出来
/usr/local/php/bin/phpize //再来这个试试看,
./configure --with-php-config=/usr/local/php/bin/php-config //configure出来了
configure: error: Cannot find OpenSSL's <evp.h> //又来个error
//什么意思,看不懂,复制张贴去百度。好了,yum install openssl openssl-devel
yum install openssl openssl-devel //下载需要的依赖,openssl
./configure --with-php-config=/usr/local/php/bin/php-config //再来一次
make && make install
cd /usr/local/php/lib //这个我放php.ini
vim php.ini //vim编辑
extension="openssl.so" //最后面加上去
php -m //出来了,完成。
网友评论