PHP7 學習筆記(五)安裝event擴展(libevent)


一、描述:有效安排I/O,時間和信號的擴展 使用可用於特定平台的最佳I/O通知機制的事件,是PHP基礎設施的libevent端口。

二、下載地址:http://pecl.php.net/package/event

三、安裝支持庫libevent,需要編譯高版本(這里以最新版本release-2.1.8-stable為例)

1、下載地址:https://github.com/nmathewson/Libevent.git

git clone https://github.com/nmathewson/Libevent.git

2、注意:如果您從git存儲庫獲取libevent,則首先需要運行包含的“autogen.sh”腳本以生成configure腳本。

cd Libevent/ ./autogen.sh

3、可能會提示錯誤信息:

configure.ac:129: error: possibly undefined macro: AC_PROG_LIBTOOL If this token and others are legitimate, please use m4_pattern_allow. See the Autoconf documentation. autoreconf: /usr/bin/autoconf failed with exit status: 1

解決辦法:

sudo apt-get install libtool

4、生成 Makefile,同時指定安裝路徑,為下一步的編譯做准備

./configure --prefix=/usr/local/libevent-2.1.8 make sudo make install

四、安裝event庫(以event-2.3.0.tgz為例)

1、官方地址:http://pecl.php.net/package/event

2、下載解壓

wget http://pecl.php.net/get/event-2.3.0.tgz
tar -zxvf event-2.3.0.tgz

3、查找對應的phpize

/usr/local/php-7.1.8/bin/phpize

查找配置文件:

www@Tinywan:~/DEMO/event-2.3.0$ sudo find / -name php-config /usr/local/php-7.1.8/bin/php-config

4、生成 Makefile,同時指定安裝路徑,為下一步的編譯做准備

./configure --with-php-config=/usr/local/php-7.1.8/bin/php-config --with-event-libevent-dir=/usr/local/libevent-2.1.8/

5、編譯安裝,重啟服務器

make
sudo make install

6、修改配置文件php.ini,添加以下內容

extension=/usr/local/php-7.1.8/lib/php/extensions/no-debug-non-zts-20160303/event.so

7、重啟服務器,查看擴展是否安裝成功

sudo systemctl restart php-fpm.service php -m php -m | grep event

8、結束

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM