Ubuntu安装mqtt服务¶
- 安装
apt install mosquitto
- 修改监听端口和IP
vim /etc/mosquitto/mosquitto.conf listener 1883 0.0.0.0
- 设置用户名密码
cp /etc/mosquitto/pwfile.example /etc/mosquitto/pwfile mosquitto_passwd -c /etc/mosquitto/pwfile test test123
注:不设置用户名密码,可能报错:Client <unknown> disconnected, not authorised. - 重启服务
systemctl restart mosquitto