Linux下php安裝mysql擴展

第一步:進入php源碼中的"ext/mysql"目錄下
第二步:在當前目錄下運行phpize

命令:/usr/local/php/bin/phpize 

成功結果如下:
[root@localhost mysql]# /usr/local/php/bin/phpize
Configuring for:
PHP Api Version:         20100412
Zend Module Api No:      20100525
Zend Extension Api No:   220100525

第三步:運行剛纔生成的configure文件
命令:./configure --with-php-config=/usr/local/php/bin/php-config --with-mysql=/usr

此時會出現如下錯誤:
configure: error: Cannot find MySQL header files under /usr

解決類似問題使用如下命令:
命令:./configure --with-php-config=/usr/local/php/bin/php-config --with-mysql=/usr --with-libdir=lib64

成功後最後幾行顯示如下信息:
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no

creating libtool
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h

第四步:編譯執行
命令:make && make install
成功後顯示如下信息:

第五步:在php.ini中添加mysql擴展
在php.ini文件的最後添加一行:
extension = mysql.so
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章