linux下PHP手動添加擴充庫

來源:互聯網
上載者:User

標籤:php擴充

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)

組建組態檔案,並編譯產生模組:

/usr/local/php/bin/phpize

./configure --with-php-config=/usr/local/php/bin/php-config

650) this.width=650;" title="Image(5)" border="0" alt="Image(5)" src="http://images2015.cnblogs.com/blog/605186/201512/605186-20151216092403631-1014627595.png" width="543" height="491" style="border:0px;padding-top:0px;padding-left:0px;padding-right:0px;background-image:none;" />


make


650) this.width=650;" title="Image(6)" border="0" alt="Image(6)" src="http://images2015.cnblogs.com/blog/605186/201512/605186-20151216092405037-834711096.png" width="601" height="512" style="border:0px;padding-top:0px;padding-left:0px;padding-right:0px;background-image:none;" />


make install


650) this.width=650;" title="Image(7)" border="0" alt="Image(7)" src="http://images2015.cnblogs.com/blog/605186/201512/605186-20151216092406256-834233930.png" width="596" height="58" style="border:0px;padding-top:0px;padding-left:0px;padding-right:0px;background-image:none;" />


這樣,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

./configure --with-freetype-dir=/usr/local/freetype --with-php-config=/usr/local/php/bin/php-config

2.在安裝pdo_mysql擴充時

/usr/local/php/bin/phpize

./configure --with-php-config=/usr/local/php/bin/php-config

make後出現如下錯誤:

650) this.width=650;" title="Image(8)" border="0" alt="Image(8)" src="http://images2015.cnblogs.com/blog/605186/201512/605186-20151216092408224-891609765.png" width="784" height="53" style="border:0px;padding-top:0px;padding-left:0px;padding-right:0px;background-image:none;" />

意思是在php_pdo_mysql_int.h的第27行包含檔案時沒有找到他他所需的mysqlnd.h 但實際上在ext/mysqlnd中能找到mysqlnd.h因此大致是他的包含路徑有問題 ,編輯php_pdo_mysql_int.h  定位到27行改成如下(改成能直接存取到相應標頭檔的路徑)

650) this.width=650;" title="Image(9)" border="0" alt="Image(9)" src="http://images2015.cnblogs.com/blog/605186/201512/605186-20151216092413131-751508369.png" width="786" height="144" style="border:0px;padding-top:0px;padding-left:0px;padding-right:0px;background-image:none;" />


本文出自 “夢想照進現實” 部落格,請務必保留此出處http://lookingdream.blog.51cto.com/5177800/1862606

linux下PHP手動添加擴充庫

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.