標籤:php zabbix bcmath sockets 動態載入 模組
在學習安裝zabbix的時候,前提需要搭建使用到LNMP架構,而在編譯php時忘記添加bcmath與sockets
擴充包,發現當初安裝時沒有--enable-bcmath、--enable-sockets,自己又不想刪除重裝php,幸好php支
持單獨添加某個extension,重要的就是要產生這個擴充對應的.so檔案。
650) this.width=650;" src="https://s2.51cto.com/wyfs02/M02/93/3A/wKioL1kJfJfx4ctaAACXdcKMOhM151.png-wh_500x0-wm_3-wmp_4-s_3112701599.png" title="QQ20170428140530.png" alt="wKioL1kJfJfx4ctaAACXdcKMOhM151.png-wh_50" />
具體做法如下,要有與你已安裝的php相同版本的php原始碼安裝包。我用的是php-7.0.5.tar.gz。
[[email protected] ~]# tar -zxf php-7.0.5.tar.gz
[[email protected] ~]# cd php-7.0.5
[[email protected] php-7.0.5]# cd ext/
[[email protected] ext]# cd bcmath/
[[email protected] bcmath]# /usr/local/php7/bin/phpize
[[email protected] bcmath]# ./configure --with-php-config=/usr/local/php7/bin/php-config --enable-bcmath
[[email protected] bcmath]# make
[[email protected] bcmath]# make test
[[email protected] bcmath]# make install
[[email protected] bcmath]# cd /usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012
[[email protected] no-debug-non-zts-20151012]# ls
bcmath.so opcache.a opcache.so
模組編譯好了,現在添加進php
[[email protected] no-debug-non-zts-20151012]# cd /usr/local/php7/etc/
[[email protected] etc]# vi php.ini
在最後面增加兩行
extension_dir=/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20090626/
extension=mbstring.so
重啟php及nginx,測試模組加上了。
遇到的問題:
在編譯bcmath時要加上 --with-php-config=/usr/local/webserver/php/bin/php-config 不然會出現下面錯誤
configure: error: Cannot find php-config. Please use --with-php-config=PATH
[[email protected] bcmath]# ./configure --with-php-config=/usr/local/webserver/php/bin/php-config 正常。
同樣的方法進行sockets庫模組的動態添加。
php服務源碼安裝包中沒有的ext目錄下面,如果沒有找到所需的載入模組(例如yaf、ffmpeg),需要自己下載其源碼安裝包,解壓後的操作與上面的步驟一樣。
這個問題是在我做zabbix實驗的時候遇到的,在php動態載入模組這方面又加深了一次。
本文出自 “MQ_douer” 部落格,請務必保留此出處http://douer.blog.51cto.com/6107588/1921572
php動態擴充bcmath與sockets庫模組