直接升级可能会带来一些问题。如异步redis、http2等之前没有编译。
1、swoole升级:pecl upgrade swoole
2、查看版本:php --ri swoole | grep Version
如果你需要解决问题向下看,下面我们来重新安装并编译一些功能项:
下载swoole最新版本
swoole-swoole-v4.2.2.zip
编译:
1、phpize
2、./configure --enable-coroutine --enable-openssl --enable-http2 --enable-async-redis --enable-sockets --enable-mysqlnd
3、make && make install
注意:openssl、nghttp2、hiredis需要安装拓展文件
1、openssl
如果你安装则需要 "拷贝openssl文件夹" 到swoole v4.2.2[找自己文件实际目录]/include/ 下。
找到你们的openssl文件夹,把它拷贝到swoole安装包下的include下面,我的openssl文件的目录为/usr/local/opt/openssl/include 把这个路径下的openssl文件夹copy到安装文件夹中的include下就ok了。
如果还是报错修改环境变量:
.profile
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
source ~/.profile
2、http2安装
下载文件nghttp2
1、wget https://github.com/nghttp2/nghttp2/releases/download/v1.30.0/nghttp2-1.30.0.tar.bz2
2、tar -jxvf nghttp2-1.30.0.tar.bz2
3、cd nghttp2-1.30.0
4、./configure
5、make && make install
如果没报错则表示安装nghttp2成功。
3、hiredis安装
问题描述:
安装swoole时,
想启用异步redis功能,
于是添加了 –enable-async-redis 选项,
但是在编译时出错,
提示“hiredis/hiredis.h: No such file or directory”
这个原因是没有安装 hiredis导致。
解决办法也很简单,
安装 hiredis 即可
wget https://github.com/redis/hiredis/archive/v0.13.3.tar.gz
mv v0.13.3.tar.gz hiredis-0.13.3.tar.gz
tar xzvf hiredis-0.13.3.tar.gz
cd hiredis-0.13.3
make && make install
添加环境变量
vi ~/.profile
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
在最后一行添加
然后运行:source ~/.bash_profile
重新编译swoole安装。
编译:
1、phpize
2、./configure --enable-coroutine --enable-openssl --enable-http2 --enable-async-redis --enable-sockets --enable-mysqlnd
3、make && make install
augdais-MacBook-Pro:swoole-v4.2.2 augdai$ php --ri swoole | grep Version
Version => 4.2.2
结束。