Welcome to MQTT Essentials – a series on the fundamental features and principles of the MQTT protocol. In this post, I will show you how to install MQTT broker on macOS (known as OS X before version Sierra).
I. Install Homebrew:
- Paste the following command onto a macOS Terminal or Linux shell prompt (refer to https://brew.sh for updated packages)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- It should ask you to enter the password of your device (the password won’t show as you type). Then, you follow the instruction on the screen. The entire installing process can take up to half an hour. When finished, you will see something like this:
- Follow ‘Next steps’ to add Homebrew to your PATH
II. Install mosquitto (MQTT):
- Open a Terminal window and run the following command to request Homebrew to install Mosquitto:
brew install mosquitto
2. The following lines are the last messages shown in the Terminal. It indicates Homebrew has installed Mosquitto and the instructions to start the MQTT server.
3. Next, run the following command (as in the red box above) to launch Mosquitto with the default configuration file.
/opt/homebrew/opt/mosquitto/sbin/mosquitto -c /opt/homebrew/etc/mosquitto/mosquitto.conf
The following is the output after you run the previous command:
The last lines indicate an IPv4 and an IPv6 listen socket on port 1883 have been opened by the Mosquitto MQTT server. We need Mosquitto running on the local computer to work on our projects, so keep the Terminal window open!
Howdy! Installing the MQTT broker on MacOS is not that hard, is it? Let me know if you have any questions!
Worked perfectly!!!
Thank you.
I’m glad this helps!