Mac下安装event库
因為使用的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了!
總結
以上是生活随笔為你收集整理的Mac下安装event库的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: LAMP部署脚本--安装篇
- 下一篇: shell 小米system锁adb_小