1.進入php源程式目錄中的ext目錄中,這裡存放着各個擴充子產品的源代碼,選擇你需要的子產品,比如curl子產品:
cd curl
執行phpize生成編譯檔案,phpize在PHP安裝目錄的bin目錄下
/usr/local/php/bin/phpize
運作時,可能會報錯:Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF
environment variable is set correctly and then rerun this script.“,需要安裝autoconf:
yum install autoconf(RedHat或者CentOS)、apt-get install autoconf(Ubuntu Linux)
生成配置檔案,并編譯生成子產品:
./configure --with-php-config=/usr/local/php/bin/php-config

make
make install
這樣,curl.so就被複制到PHP對應目錄(如:/usr/local/php/lib/php/extensions/no-debug-zts-20131226)
2.修改配置
在php.ini裡,設定擴充目錄:
extension_dir = "/usr/local/php/lib/php/extensions/no-debug-zts-20131226"
并添加擴充子產品引用:
extension = curl.so
3.檢查并重新開機Apache
/usr/local/php/bin/php -v
執行這個指令時,php會去檢查配置檔案是否正确,如果有配置錯誤,這裡會報錯,可以根據錯誤資訊去排查
補充:
1.需要安裝自己手動編譯的擴充包時在ext目錄中如下指定
以下為在/ext/gd檔案下安裝gd庫是順便使其支援freetype
<code>.</code><code>/configure</code> <code>--with-freetype-dir</code><code>=</code><code>/usr/local/freetype</code> <code>--with-php-config=</code><code>/usr/local/php/bin/php-config</code>
2.在安裝pdo_mysql擴充時
make後出現如下錯誤:
意思是在php_pdo_mysql_int.h的第27行包含檔案時沒有找到他他所需的mysqlnd.h 但實際上在ext/mysqlnd中能找到mysqlnd.h是以大緻是他的包含路徑有問題 ,編輯php_pdo_mysql_int.h 定位到27行改成如下(改成能直接通路到相應頭檔案的路徑)
本文轉自yzy121403725 51CTO部落格,原文連結:http://blog.51cto.com/lookingdream/1862606,如需轉載請自行聯系原作者