php下安装event扩展

安装支持库libevent,需要编译高版本(这里以最新版本release-2.1.8-stable为例)

1
2
3
4
5
wget -c https://github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gz -P /opt/local/src
cd /opt/local/src
tar -zxvf libevent-2.1.8-stable.tar.gz && cd libevent-2.1.8-stable
./configure --prefix=/opt/local/libevent
make && make install

安装event库(以event-2.3.0.tgz为例)

1
2
3
4
5
6
wget -c http://pecl.php.net/get/event-2.3.0.tgz -P /opt/local/src
cd /opt/local/src
tar -zxvf event-2.3.0.tgz && cd event-2.3.0
/opt/local/php72/bin/bin/phpize
./configure --with-php-config=/opt/local/php72/bin/php-config --with-event-libevent-dir=/opt/local/libevent/
make && make install

在php.ini添加下面配置

1
extension=event.so