安裝 Mosquitto:
bash
複製程式碼
sudo apt update
sudo apt install -y mosquitto mosquitto-clients
啟動 Mosquitto 服務:
bash
複製程式碼
sudo systemctl start mosquitto
sudo systemctl enable mosquitto
驗證安裝是否成功:
bash
複製程式碼
mosquitto -v
若安裝成功,應該會顯示 Mosquitto 版本號。
成功的畫面
ai🍓raspberrypi:~ 🍓 mosquitto -v
1727455887: mosquitto version 2.0.11 starting
1727455887: Using default config.
1727455887: Starting in local only mode. Connections will only be possible from clients running on this machine.
1727455887: Create a configuration file which defines a listener to allow remote access.
1727455887: For more details see https://mosquitto.org/documentation/authentication-methods/
1727455887: Opening ipv4 listen socket on port 1883.
1727455887: Opening ipv6 listen socket on port 1883.
1727455887: mosquitto version 2.0.11 running