本文目錄一覽:
如何在編譯好的PHP環境中安裝PHP擴展模塊
1、先進入php解壓縮後的源碼包中,找到要安裝的擴展模塊的目錄。
[root@redhat5 sockets]# cd /home/soft/php-5.2.12/ext/sockets
在sockets目錄下面以絕對路徑運行phpize程序,這時會自動生成sockets的configure程序,在sockets目錄下面可以看到。
[root@redhat5 sockets]# /home/webserver/php5.2.12/bin/phpize
2、進行編譯安裝
[root@redhat5 sockets]# ./configure –with-php-config=/home/webserver/php5.2.12/bin/php-config
[root@redhat5 sockets]#make
[root@redhat5 sockets]#make install
執行完make install屏幕上會提示sockets.so存放的路徑,然後把它複製到php的extensions目錄中,例如我的路徑為 /home/webserver/php5.2.12/lib/php/extensions
3、修改php.ini文件
找到extension_dir = “./” 這行,修改為:
extension_dir = “/home/webserver/php5.2.12/lib/php/extensions/”
然後再新增加一行:
extension=sockets.so
4、重啟apache即可生效。
PHP的擴展模塊怎麼添加?
php安裝好後,可能在初次安裝時,會有些模塊會有遺漏,但是我們又不想重新編譯php,因為耗時是比較長的。我們可不可以在不重新編譯安裝php的情況下,來為php單獨添加某一個模塊呢?查找資料,發現還是有方法的,重點就是phpize了,於是寫了這篇文章.
下面我們就以單獨為php載入mysqli模塊為例,演示如何動態為php添加模塊。
1、找到php原碼安裝文件
2、cd /home/php/ext/myslqi
3、運行 /usr/local/php/bin/phpize
4、/configure –with-php-config=/usr/local/php/bin/php-config
5、make make install
6、安裝完成之後會在系統/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/這個目錄下面生成mysqli.so的庫文件
7、編輯php.ini文件,指定php到哪人目錄讀取模塊
vi /usr/local/php/etc/php.ini
extension_dir=」/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613″
extension=mysqli.so
8、重啟php服務 /usr/local/php/sbin/php-fpm restart
7、/usr/local/php/bin/php -m|grep mysqli 查看mysqli.so是否存在
如果步驟正確,你的人口也不差的情況下,應該這樣php的動態模塊載入就完成了。
如何擴展PHP的IMAP模塊
如果對php進行模塊擴展,重新編譯PHP,這個過程比較痛苦,我的方法都是採用編譯模塊為*.so的方式,簡單,方便,不用去其他地方找模塊源碼包,php源碼自帶了。
1、進入安裝目錄
cd /path/ext/imap
/usr/local/webserver/php/bin/phpize
./configure –with-php-config=/usr/local/webserver/php/bin/php-config
就是到這步報錯了,如果你碰到這樣的錯誤:
This c-client library is built with Kerberos support.
Add –with-kerberos to your configure line. Check config.log for details
utf8_mime2text() has new signature
以上2個錯誤都是由於缺少 libc-client-* 軟體包引起,由於我是Centos系統,就直接yum升級吧
yum -y install libc-client-*
安裝完畢後,再次編譯,
./configure –with-php-config=/usr/local/webserver/php/bin/php-config
這次的錯誤不一樣,如下:
configure: error: Kerberos libraries not found.
Check the path given to –with-kerberos (if no path is given, searches in /usr/kerberos, /usr/local and /usr )
既然提示少參數,就加上該參數吧,
./configure –with-php-config=/usr/local/webserver/php/bin/php-config –with-kerberos=/usr
注意:這裡有3個路徑可以選擇,於是就一個一個試一下,很幸運的是前面2個都不能編譯通過,只有 –with-kerberos=/usr 可以,但是還是有報錯,如下:
This c-client library is built with SSL support
看來離希望越來越近了,於是就加上 –with-imap-ssl=/usr 參數,終於編譯通過了,真不容易。
最後完整的編譯 imap 模塊參數如下:
./configure –with-php-config=/usr/local/webserver/php/bin/php-config –with-kerberos=/usr –with-imap-ssl=/usr
make
make install
原創文章,作者:SMNN,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/131740.html