因为使用的GatewayWorker框架使用了swoole,但swoole依赖于event,所以必须安装下event扩展!
1. 最初使用brew install libevent安装了下,运行gatewayworker发现错误依然存在!
2. 考虑到是php里使用event,所以改用pecl去安装,先用pecl search event搜索了下,结果如下:
[zcm@7.2 47]$pecl search event
Retrieving data...0%
.Matched packages, channel pecl.php.net:
=======================================
Package Stable/(Latest) Local
event 2.4.1 (stable) Provides interface to libevent library
libevent 0.1.0 (beta) Libevent - event notification
但是用pecl install libevent时,发现因为这个版本是beta版本,所以下载失败。。。。
改用pecl install event,安装过程中因为无法找到openssl的库路径而安装失败,因此改用先下载安装包,再自行解压安装
3. pecl download event
tar -zxvf event-2.4.1.tgz
cd event event-2.4.1
phpize
./configure --with-php-config=/usr/local/opt/php/bin/php-config --enable-event-debug=yes --enable-event-sockets=yes --with-event-libevent-dir=/usr --with-event-pthreads --with-event-extra --with-event-openssl --with-event-ns --with-openssl-dir=/usr/local/Cellar/openssl/1.0.2o_1
make
make install
编译并安装完成!
4. 配置
mvim /usr/local/etc/php/7.2/php.ini
添加: extension="event.so"
保存并退出
5. 测试:
php -m | grep event
如果有event就说明对了
===========================================================
同样, 安装php的swoole扩展时如果启用openssl, 可能也会遇到同样的问题, 在一系列的折腾后, 在以下目录发现有用的脚本文件:
[zcm@swoole-4.3.5 14]$pwd
/Users/zcm/Downloads/swoole-4.3.5
[zcm@swoole-4.3.5 15]$cat make.sh
phpize --clean
phpize
./configure --enable-openssl --enable-sockets --enable-mysqlnd --enable-http2
make clean
make -j
make install
根据我自己电脑上openssl库的路径,在./configure命令中加入了以下参数" --with-openssl-dir=/usr/local/Cellar/openssl/1.0.2s"
再执行sh make.sh, 最后安装成功, 安装成功后, 记得要在php.ini文件中启用swoole扩展, 即添加: extension="swoole.so"
最后在命令行中执行: php -m | grep swoole 检测是否有swoole了!