swoole安装基本配置
来源:互联网 发布:淘宝退货金额改0元吗 编辑:程序博客网 时间:2024/06/05 02:34
php安装swoole
1. 下载swoole安装
```wget http://pecl.php.net/get/swoole-1.9.1.tgztar -zxvf swoole-1.9.1.tgzcd swoole-1.9.1phpize./configuremakemake install```
2. 在php.ini添加swoole.so
```extension=swoole.so```
3. php文件
```<?php$server = new swoole_websocket_server("0.0.0.0", 9501);$server->on('open', function (swoole_websocket_server $server, $request) { echo "server: handshake success with fd{$request->fd}\n";});$server->on('message', function (swoole_websocket_server $server, $frame) { echo "receive from {$frame->fd}:{$frame->data},opcode:{$frame->opcode},fin:{$frame->finish}\n"; $server->push($frame->fd, "这是服务器消息!");});$server->on('close', function ($ser, $fd) { echo "client {$fd} closed\n";});$server->start();```
4. html文件
```<!DOCTYPE html><html><head> <title>欢迎使用swoole!</title></head><body><script type="text/javascript"> // 创建一个Socket实例 var socket = new WebSocket('ws://192.168.1.127:9501/'); // 打开Socket socket.onopen = function(event) { // 发送一个初始化消息 socket.send('我是客户端并且正在监听。'); // 监听消息 socket.onmessage = function(event) { console.log('客户端接收到一个消息。',event); }; // 监听Socket的关闭 socket.onclose = function(event) { console.log('客户端通知套接字已关闭。',event); }; // 关闭Socket.... //socket.close() };</script><h1>欢迎使用swoole!</h1></body></html>```
5. 打开防火墙9501端口
```firewall-cmd --zone=public --add-port=9501/tcp --permanentsystemctl restart firewalld```
6.. 启动swoole服务
```php /usr/local/nginx-1.11.5/html/index.php```
0 0
- swoole安装基本配置
- swoole 安装
- swoole 安装
- swoole 安装
- 安装swoole
- MAMP配置swoole
- phpstudy 安装 swoole扩展
- Mac 安装swoole
- Centos Swoole安装
- swoole编译安装
- ubuntu下swoole安装
- windows swoole安装
- php 安装 swoole 扩展
- php安装swoole扩展
- Liunx Swoole 安装
- Swoole编译安装
- mac 下安装swoole
- swoole 安装方法
- 指针的指针和指针的引用
- Nignx基本操作(启动、停止、重启)以及信号控制
- js 中 || 和 &&
- 分布式-集群模式-微服务
- 金融tag对照表
- swoole安装基本配置
- JavaScript权威指南--基础篇3
- Android中allowBackup属性的含义和危险性实例讲解
- 揭秘信用卡账单、支付宝背后的黑色产业链
- Activity生命周期详解(为什么不能在onPause里执行耗时操作)
- HDU1176
- 语音处理学习感悟汇总
- 02分治算法-02fast-power
- 【Distribution】分布式系统的事务处理