Ubuntu安装部署mqtt
一、安装
1、直接安装mqtt包
$ sudo apt-add-repository ppa:mosquitto-dev/mosquitto-ppa
$ sudo apt-get update
$ sudo apt-get install mosquitto
$ sudo apt-get install mosquitto-clients
2、从github上下载开发包后编译
二、配置
1、添加配置文件
# 如果没有这个路径,则mkdir这个路径,或者随便在哪里写一个配置文件
$ vi /usr/etc/mosquitto/mosquitto.conf
port 1883
listener 9005
protocol websockets
2、启动
$ mosquitto -c /usr/etc/mosquitto/mosquitto.conf
三、测试
1、测试监听
$ telnet localhost 9005
$ telnet localhost 1883
2、测试订阅发布
# 非本机,把localhost换成具体ip即可
$ mosquitto_sub -h localhost -p 1883 -t "topic" -v
$ mosquitto_pub -h localhost -t "topic" -m "test message"

浙公网安备 33010602011771号