Libevent 是一個用C語言寫的、輕量級的開源高效能I/O框架,支援多種I/O 多路復用技術: epoll、 poll、 dev/poll、 select 和kqueue 等;支援I/O,定時器和訊號等事件;註冊事件優先權。 PHP提供了對應的擴充 libevent、 Event 。
比起 libevent ext, event ext 有更好的效能表現和更全面的API,可以讓我們更友善的使用 Libevent。
安裝 Libevent 函式庫
php event 擴充功能 依賴 Libevent 函式庫,需要先編譯安裝(注意是 Libevent 函式庫,非 libevent 擴充功能)。
git clone --depth=1 https://github.com/nmathewson/Libevent.git cd Libevent ./autogen.sh ./configure --prefix=/usr/local/libevent make && make install
登入後複製
安裝Event 擴充功能
可以直接使用pecl
安裝
pecl install event downloading event-2.5.3.tgz ... Starting to download event-2.5.3.tgz (140,913 bytes) ..............................done: 140,913 bytes 50 source files, building running: phpize Configuring for: PHP Api Version: 20180731 Zend Module Api No: 20180731 Zend Extension Api No: 320180731 Enable internal debugging in Event [no] : Enable sockets support in Event [yes] : libevent installation prefix [/usr] : /usr/local/libevent ... Build process completed successfully Installing '/usr/local/php/lib/php/extensions/no-debug-non-zts-20180731/event.so' install ok: channel://pecl.php.net/event-2.5.3 Extension event enabled in php.ini
登入後複製
查看安裝結果
[root@localhost ~]# php --ri event event Event support => enabled Sockets support => enabled Debug support => disabled Extra functionality support including HTTP, DNS, and RPC => enabled OpenSSL support => enabled Thread safety support => disabled Extension version => 2.5.3 libevent2 headers version => 2.2.0-alpha-dev
登入後複製