如何在 Ubuntu 中将 mosquitto 更新到最新版本

S A*_*rew 5 ubuntu version updates mosquitto

我已经mosquitto使用ubuntu命令安装:

sudo apt-get install mosquitto
Run Code Online (Sandbox Code Playgroud)

安装的mosquitto版本是1.6.9。

mosquitto version 1.6.9

mosquitto is an MQTT v3.1.1 broker.

Usage: mosquitto [-c config_file] [-d] [-h] [-p port]

 -c : specify the broker config file.
 -d : put the broker into the background after starting.
 -h : display this help.
 -p : start the broker listening on the specified port.
      Not recommended in conjunction with the -c option.
 -v : verbose mode - enable all logging types. This overrides
      any logging options given in the config file.

See http://mosquitto.org/ for more information
Run Code Online (Sandbox Code Playgroud)

为了将mosquitto更新到最新版本,我首先将其卸载,然后运行命令sudo apt-get update,然后重新安装mosquitto,但版本仍然相同。

如何将 mosquitto 更新到最新版本?

WaL*_*oui 3

如果您想要更新版本的mosquittoUbuntu,但使用的是旧版本的 Ubuntu,那么通过阅读此处的官方下载页面,您会发现有不止一种方法可以安装最新的 mosquitto 版本:

  1. 直接从源代码编译和构建,我不建议这样做(特别是对于初学者)。
  2. 使用mosquitto-dev PPA
  3. 通过简单地运行来使用 snap 包而不是 aptsudo snap install mosquitto

不过,我认为最好的方法是使用mosquitto-dev PPA从源代码构建 mosquitto 需要更多的时间和精力,并且使用 snap 需要更多的步骤来启动和运行它。

所以..首先卸载旧的mosquitto版本:

sudo apt autoremove mosquitto
Run Code Online (Sandbox Code Playgroud)

那么你需要添加mosquitto-dev PPA到你的来源列表中:

sudo apt-add-repository ppa:mosquitto-dev/mosquitto-ppa 
sudo apt-get update
Run Code Online (Sandbox Code Playgroud)

最后,安装mosquitto:

sudo apt install mosquitto 
Run Code Online (Sandbox Code Playgroud)

只需运行即可验证您的安装mosquitto --help,输出应如下所示:

mosquitto version 2.0.10

mosquitto is an MQTT v5.0/v3.1.1/v3.1 broker.

Usage: mosquitto [-c config_file] [-d] [-h] [-p port]

 -c : specify the broker config file.
 -d : put the broker into the background after starting.
 -h : display this help.
 -p : start the broker listening on the specified port.
      Not recommended in conjunction with the -c option.
 -v : verbose mode - enable all logging types. This overrides
      any logging options given in the config file.

See https://mosquitto.org/ for more information.
Run Code Online (Sandbox Code Playgroud)

恭喜您现在已经安装了最新版本。