1. 程式人生 > >動態新增php擴充套件模組

動態新增php擴充套件模組

有時php編譯安裝好之後,發現摸個編譯引數漏掉了,需要的模組不支援但又不想重新編譯php,這時我們可以動態的新增php模組。
如我之前有一個編譯時漏掉了--enable-mbstring 現在給新增上。
新增擴充套件模組只要在php的安裝包裡找到相應的模組原始碼重新編譯後,新增到php擴充套件就可以。
[[email protected] php-5.3.18]# ls ext/
bcmath              fileinfo   mbstring      pdo_mysql   simplexml  tokenizer
bz2                 filter     mcrypt        pdo_oci     skeleton   wddx
                                      ...             .....
[
[email protected]
php-5.3.18]# cd ext/mbstring/
[[email protected] mbstring]# pwd
/root/soft/php-5.3.18/ext/mbstring
執行phpize:
[[email protected] mbstring]# /usr/local/webserver/php/bin/phpize 
提示:
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.
安裝autoconf:
[
[email protected]
mbstring]# yum install autoconf
[[email protected] mbstring]# /usr/local/webserver/php/bin/phpize 
[[email protected] mbstring]# ./configure   --with-php-config=/usr/local/webserver/php/bin/php-config 
[[email protected] mbstring]# make
[[email protected] mbstring]# make install
Installing shared extensions:     /usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20090626/
Installing header files:          /usr/local/webserver/php/include/php/
[
[email protected]
etc]# ls /usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20090626
mbstring.so
模組編譯好了,現在新增進php
[[email protected] etc]# vi php.ini 
在最後面增加兩行
extension_dir=/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20090626/
extension=mbstring.so
重啟php,測試模組加上了。
遇到的問題:
在編譯mbstring時要加上  --with-php-config=/usr/local/webserver/php/bin/php-config 不然會出現下面錯誤
configure: error: Cannot find php-config. Please use --with-php-config=PATH
[[email protected] mbstring]# ./configure   --with-php-config=/usr/local/webserver/php/bin/php-config 
正常。