下面以安裝curl爲例,介紹具體安裝步驟。php
1.安裝crul wget http://curl.haxx.se/download/curl-7.19.6.tar.gz tar -zxvf curl-7.19.6.tar.gz cd curl-7.19.6 ./configure –prefix=/usr/local/curl服務器
makecurl
make installthis
2.編譯生成擴展進入php源程序目錄中的ext目錄中,這裏存放着各個擴展模塊的源代碼,選擇你須要的模塊,好比curl模塊:url
cd curlspa
執行phpize生成編譯文件,phpize在PHP安裝目錄的bin目錄下debug
/usr/local/php5/bin/phpizexml
運行時,可能會報錯:Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable is set correctly and then rerun this script.「,須要安裝autoconf:ip
yum install autoconf(RedHat或者CentOS)、apt-get install autoconf(Ubuntu Linux)pdo
生成配置文件,並編譯生成模塊:
/usr/local/php5/bin/phpize
./configure –with-curl=/usr/local/curl –with-php-config=/usr/local/php5/bin/php-config
make
make install
這樣,curl.so就被複制到PHP對應目錄(如:/usr/local/php5/lib/php/extensions/no-debug-non-zts-20090626/)
3.修改配置在php.ini裏,設置擴展目錄:
extension_dir = 「/usr/local/php5/lib/php/extensions/no-debug-non-zts-20090626/」
並添加擴展模塊引用:
extension = curl.so
4.檢查並重啓Apache
/usr/local/php/bin/php -v
執行這個命令時,php會去檢查配置文件是否正確,若是有配置錯誤,這裏會報錯,能夠根據錯誤信息去排查