linux下php开启pdo扩展

  • 前提:网页报错 

         为解决问题:Undefined class constant 'MYSQL_ATTR_INIT_COMMAND'

解决方案 :

  • 下载安装PHP_MYSQL扩展

wget http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz
tar xvf PDO_MYSQL-1.0.2.tgz
cd PDO_MYSQL-1.0.2
/usr/local/php-5.6.30/bin/phpize
./configure --with-php-config=/usr/local/php-5.6.30/bin/php-config --with-pdo-mysql=/usr/local/mysql-5.7.21/ --with-zlib-dir=/usr/local/lib
make
make install

  • 报错解决/usr/local/src/PDO_MYSQL-1.0.2/php_pdo_mysql_int.h:25:19: fatal error: mysql.h: No such file or directory

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

  • PDO_MYSQL安装成功后,继续,开启PHP对应扩展

vim /usr/local/php-5.6.30/etc/php.ini

#在文件末尾增加 extension=pdo_mysql.so

  • 报错解决libmysqlclient.so.20: cannot open shared object file: No such file or directory in Unknown

ln -s /usr/local/mysql-5.7.21/lib/libmysqlclient.so.20 /usr/lib64/libmysqlclient.so.20

  • 重启PHP服务

 

 Done!

 

参考地址:

https://blog.csdn.net/houdaiye/article/details/51965640

http://www.codeweblog.com/pdo_mysql-1-0-2-php_pdo_mysql_int-h-25-19-%E8%87%B4%E5%91%BD%E9%94%99%E8%AF%AF/

https://www.cnblogs.com/eRrsr/p/8258333.html

posted on 2018-06-08 17:48  爱吃柠檬不加糖  阅读(435)  评论(0编辑  收藏  举报

导航