swoole安装需要:linux7 +php5.3.10以上版本+gcc-4.4 或更高版本
下载地址:
- https://github.com/swoole/swoole-src/releases
- http://pecl.php.net/package/swoole
- http://git.oschina.net/swoole/swoole
编译安装
1.进入swoole目录,准备调出 configure(swoole默认是没有这个文件)
# cd /down/swoole-src-4.0.3 # /usr/local/php/bin/phpize
2.开始配置
# ./configure --with-php-config=/usr/local/php/bin/php-config
如果报错:
configure: error: C++ preprocessor "/lib/cpp" fails sanity check See `config.log' for more details.
解决办法:
yum install glibc-headers
yum install gcc-c++
3.编译安装
make && make install
PECL安装
配置php.ini (路径:/usr/local/php/lib)
// 加入代码 extension=swoole.so
查看swoole是否安装成功
1.phpinfo
2.# php -m
查看服务状态是否正常
netstat -anpt
(如果出现9501 端口,说明已经被监听,已经启动)
swoole启动
# php swoole.php // 查看swoole服务参数
# php swoole.php -h127.0.0.1 -p9501 -ntest start
扩展:
[root@izj6caq78lhbigkbmd3jd9z test.zhouzhongjie.com]# netstat -anp | grep 9501 tcp 0 0 0.0.0.0:9501 0.0.0.0:* LISTEN 8157/php [root@izj6caq78lhbigkbmd3jd9z test.zhouzhongjie.com]# pkill 0 [root@izj6caq78lhbigkbmd3jd9z test.zhouzhongjie.com]# netstat -anp | grep 9501 tcp 0 0 0.0.0.0:9501 0.0.0.0:* LISTEN 8157/php [root@izj6caq78lhbigkbmd3jd9z test.zhouzhongjie.com]# kill -9 8157