標籤:
一、下載相應tgz包;
http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz
二、安裝開始
解壓
# tar zxvf PDO_MYSQL-1.0.2.tgz
# cd PDO_MYSQL-1.0.2
運行命令
# /usr/local/php/bin/phpize
Configuring for:
PHP Api Version: 20121212
Zend Module Api No: 20060613
Zend Extension Api No: 220060519
如果運行/usr/local/php/bin/phpize 出現Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script. 那麼說明沒有autoconf
那麼執行命令 yum install m4
yum install autoconf
配置
./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql
如果配置
如果執行時報錯
configure: warning: You will need re2c 0.12.0 or later if you want to regenerate PHP parsers.
checking for gawk... gawk
checking for MySQL support for PDO... yes, shared
checking for mysql_config... not found
configure: error: Cannot find MySQL header files under
解決辦法:
cp /usr/local/mysql/bin/mysql_config /usr/bin
編譯
如果執行時報錯
/PDO_MYSQL-1.0.2/php_pdo_mysql_int.h:25:19: error: mysql.h: No such file or directory
In file included from /software/PDO_MYSQL-1.0.2/pdo_mysql.c:31:
/PDO_MYSQL-1.0.2/php_pdo_mysql_int.h:36: error: expected specifier-qualifier-list before ‘MYSQL‘
/PDO_MYSQL-1.0.2/php_pdo_mysql_int.h:48: error: expected specifier-qualifier-list before ‘MYSQL_FIELD‘
/PDO_MYSQL-1.0.2/php_pdo_mysql_int.h:53: error: expected specifier-qualifier-list before ‘MYSQL_RES‘
make: *** [pdo_mysql.lo] Error 1
解決辦法:
yum install mysql-devel
如果執行yum install mysql-devel錯誤仍然存在,那麼執行如下操作
這是因為在編譯時間需要mysql的頭的檔案,而它按預設搜尋找不到標頭檔的位置,所以才出現這個問題.所以要將 /usr/local/mysql/include/ 目錄下的mysql標頭檔連結到 /usr/local/include/ 的目錄下:
ln -s /usr/local/mysql/include/* /usr/local/include/
一般來說,執行完上面的命令後,應該能編譯過去 。然後再make和make install,pdo_mysql模組加進去了
三、修改php.ini;
extension_dir = "/usr/local/php/lib/php/extensions/no-debug-zts-20121212/"(no-debug-zts-20121212 該路徑名根據自己的實際情況設定)
extension = "pdo_mysql.so"
自此,PDO_MYSQL安裝完成。
http://blog.csdn.net/blueg2013/article/details/9307767
CentOs環境下PHP支援PDO_MYSQL