websocket安装与配置
时间: 2023-11-18 14:06:13 浏览: 127
详解nginx websocket配置
以下是websocket安装与配置的步骤:
1. 安装相关依赖库
```shell
apt-get install libssl-dev libc-ares-dev uuid-dev
```
2. 下载并编译安装libwebsockets
```shell
# 下载libwebsockets
wget https://github.com/warmcat/libwebsockets/archive/v1.5-stable.tar.gz
tar -zxvf v1.5-stable.tar.gz
# 编译安装libwebsockets
cd libwebsockets-1.5-stable
mkdir build
cd build
cmake ..
make
make install
```
3. 修改系统库目录搜索路径
```shell
echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf
ldconfig
```
4. 配置mosquitto支持websocket
在mosquitto的配置文件`/etc/mosquitto/mosquitto.conf`中添加以下内容:
```
listener 9001
protocol websockets
```
5. 重启mosquitto服务
```shell
systemctl restart mosquitto
```
阅读全文