php動態擴充bcmath與sockets庫模組

來源:互聯網
上載者:User

標籤: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庫模組

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.