---
title: "centos6.5下php添加pdo_mysql扩展"
author: "czhwin"
date: "2015-01-15T09:56:09Z"
tags: []
categories: ["互联网"]
slug: "centos6-5-php-pdo-mysql"
draft: false
lastmod: "2015-01-15T09:56:09Z"
id: 2176043
url: "https://czhwin.iteye.com/blog/2176043"
---

我的Mysql是用RPM方式安装的，PHP5.5是用源码编译安装的。查看phpinfo()后，发现没有pdo\_mysql扩展。

进去到php的[源码](http://www.2cto.com/ym)包的ext中  
\[root@linux php]# cd /usr/local/src/php-5.5.18/ext/pdo\_mysql  
\[root@linux pdo\_mysql]# /opt/php/bin/phpize（phpize 命令是用来准备 [PHP](http://www.2cto.com/kf/web/php/) 外挂模块的编译环境的）  
Configuring for:  
PHP Api Version: 20041225  
Zend Module Api No: 20060613  
Zend Extension Api No: 220060519  
\[root@linux pdo\_[mysql](http://www.2cto.com/database/MySQL/)]# ./configure --with-php-config=/opt/php/bin/php-config --with-pdo-mysql=/usr (假设你的php是安装在/opt/php)  
\[root@linux pdo\_mysql]# make && makeinstall  
。。。。。。。。。。  
Build complete.  
Don't forget to run 'make test'.

Installing shared extensions:     /opt/php/lib/php/extensions/no-debug-non-zts-20121212/

修改php.ini加入  
extension="pdo\_mysql.so"

 

重启 /etc/init.d/php-fpm restart 即可