前提:网页报错
为解决问题: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./include/* /usr/local/include/
PDO_MYSQL安装成功后,继续,开启PHP对应扩展
vim /usr/local/php-5.6./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./lib/libmysqlclient.so. /usr/lib64/libmysqlclient.so.
重启PHP服务
Done!
参考地址: