• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here:Home » How to Install Mosquitto MQTT on Ubuntu Server

By Abhishek Ghosh November 28, 2022 8:30 am Updated on November 28, 2022

How to Install Mosquitto MQTT on Ubuntu Server

Advertisement

We have already informed our readers that IBM Watson IoT platform will be discontinued sooner. We will gradually port our snippets for ESP32/Arduino to a generic MQTT platform to avoid this kind of issue in future.

As a user of the Watson IoT Platform (or as a new user) you need to know only two things to run on your server – Mosquitto and Node-RED. Thankfully a lot of work was done by IBM for MQTT. As we will use the server for production/final thing, we need to use a sub-domain, configure DNS and install a cert bot. Instead of Raspberry Pi, we are using the server:

How to Install Mosquitto MQTT on Ubuntu Server

Issue the following commands to get started :

Advertisement

---

Vim
1
2
3
4
5
6
7
8
9
10
apt update -y && apt upgrade -y
sudo add-apt-repository ppa:certbot/certbot
sudo apt install certbot mosquitto mosquitto-clients
# if ufw is installed then run these commands
sudo ufw allow 80
sudo ufw allow 8883
sudo ufw allow 8083
sudo ufw allow 1880
# change the domain name
sudo certbot certonly --standalone --preferred-challenges http -d mqtt.example.com

I guess, you can follow the instructions to complete the certbot installation. Point DNS towards the server. Make sure that the name resolves. It may take 12 hours to 2 days to complete propagation (depending upon your location).

Proceed with the installation and configure Mosquitto MQTT :

Vim
1
2
3
sudo mosquitto_passwd -c /etc/mosquitto/passwd your-username
# enter password
nano /etc/mosquitto/conf.d/default.conf

Use this kind of configuration :

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
allow_anonymousfalse
password_file /etc/mosquitto/passwd
 
listener 1883 localhost
 
listener 8883
certfile /etc/letsencrypt/live/mqtt.example.com/cert.pem
cafile /etc/letsencrypt/live/mqtt.example.com/chain.pem
keyfile /etc/letsencrypt/live/mqtt.example.com/privkey.pem
 
listener 8083
protocol websockets
certfile /etc/letsencrypt/live/mqtt.example.com/cert.pem
cafile /etc/letsencrypt/live/mqtt.example.com/chain.pem
keyfile /etc/letsencrypt/live/mqtt.example.com/privkey.pem

Restart the service, check it and set certificate renewal:

Vim
1
2
3
4
5
6
7
8
9
systemctl restart mosquitto
systemctl status mosquitto
tail /var/log/mosquitto/mosquitto.log
 
nano /etc/letsencrypt/renewal/mqtt.example.com.conf
# add it
renew_hook = systemctl restart mosquitto
# check for errors
certbot renew --dry-run

Next, install the Paho javascript client or an Android app to check whether MQTT is working. Now install Node-RED:

Vim
1
2
3
bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)
# wait till installation completes
node-red admin init

Visit mqtt.example.com:1880 in a web browser to open and log in to the Node-RED admin panel. The above things were used on the IBM Watson IoT platform.

Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to How to Install Mosquitto MQTT on Ubuntu Server

  • Nginx WordPress Installation Guide (All Steps)

    This is a Full Nginx WordPress Installation Guide With All the Steps, Including Some Optimization and Setup Which is Compatible With WordPress DOT ORG Example Settings For Nginx.

  • How to Install Mosquitto MQTT Broker/Server on Ubuntu Cloud Server

    Here is How To How to Install Mosquitto MQTT Broker/Server on Ubuntu Cloud Server So That You Need Not to Depend on Third Party MQTT Broker.

  • Update letsencrypt to certbot (Ubuntu letsencrypt 16.04 Error Fix)

    Here Are Steps To Update letsencrypt to certbot For the Users Who Used Former Before letsencrypt Became certbot. It is Mandatory For Ubuntu.

  • Easy Steps To Setup Let’s Encrypt on Ubuntu 16.04, Nginx

    Here Are Easy Steps To Setup Let’s Encrypt on Ubuntu 16.04, Nginx With HSTS, ALPN on HTTP/2, OCSP Stapling, Public Key Pinning (HPKP), Cipher.

performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Hybrid Multi-Cloud Environments Are Becoming UbiquitousJuly 12, 2023
  • Data Protection on the InternetJuly 12, 2023
  • Basics of BJT TransistorJuly 11, 2023
  • What is Confidential Computing?July 11, 2023
  • How a MOSFET WorksJuly 10, 2023
PC users can consult Corrine Chorney for Security.

Want to know more about us?

Read Notability and Mentions & Our Setup.

Copyright © 2023 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy