1.安裝libeventphp
// libevent 是一個庫,event擴展依賴這個庫並實現其功能!其實有php-libevent擴展,可是不知道什麼緣由,並不支持php7html
下載最新穩定版:wget -c https://github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gzgit
解壓:tar -zxvf libevent-2.1.8-stable.tar.gzgithub
進入目錄,配置一下安裝目錄,而後安裝bash
cd libevent-2.1.8php7
./configure --prefix=/usr/local/libevent socket
make && make install spa
2.安裝sockets擴展.net
// 若是沒有安裝這個擴展,生成event擴展的時候會提示你缺乏socket擴展code
我以前有安裝過pcntl擴展,如出一轍,這裏再也不贅述:https://www.cnblogs.com/milkone/p/9982051.html
3.安裝event擴展
下載文件:wget -c http://pecl.php.net/get/event-2.3.0.tgz
解壓:tar -zxvf event-2.3.0.tar.tgz
進入目錄 :cd event-2.3.0.tar
運行phpize: /usr/local/php7/bin/phpize
配置 :./configure --with-php-config=/usr/local/php7/bin/php-config --with-event-libevent-dir=/usr/local/libevent/
安裝:make && make install
配置文件添加擴展:echo extension = event.so >> /usr/local/php7/etc/php.ini
查看是否安裝完成:php -m
4.其餘說明
根據php官方文檔,event依賴libevent和openssl,openssl 通常在安裝php7的時候就須要安裝,這裏再也不重複安裝了