swoole搭建

linux 2018-05-23 浏览(1611 评论(0

安装

pecl install swoole

编译安装成功后,修改php.ini加入

extension=swoole.so

通过php -m或phpinfo()来查看是否成功加载了swoole,如果没有可能是php.ini的路径不对,可以使用php -i |grep php.ini来定位到php.ini的绝对路径。

php -m | grep swoole    //查看swoole是否被正确的安装

如果想要升级swoole:pecl upgrade swoole


安装出现的问题

编译swoole的时候--enable-http2的时候报如下错误

In file included from /home/xmc/download/swoole-src-2.1.0/swoole_server.c:17:0: /home/xmc/download/swoole-src-2.1.0/php_swoole.h:142:2: 错误:#error "Enable http2 support, require nghttp2 library." #error "Enable http2 support, require nghttp2 library."

这是因为swoole的http2模块依赖nghttp2库所以安装nghttp2即可

安装方式

wget https://github.com/nghttp2/nghttp2/releases/download/v1.30.0/nghttp2-1.30.0.tar.bz2
tar -jxvf nghttp2-1.30.0.tar.bz2
cd nghttp2-1.30.0
./configure
make

从头开始安装一次swoole扩展即可

打赏

如果此文对你有所帮助,请随意打赏鼓励作者^_^

黄信强博客