LoginSignup
1
2

More than 5 years have passed since last update.

Compiling mosquitto on Ubuntu 12.04LTS

Last updated at Posted at 2013-12-27

This documentation describes how to install mosquitto (Open Source MQTT Broker) by compiling source code on Ubuntu.
Typically, you can install mosquitto by using package management apt-get install mosquitto command.

Preparation

Install gcc, make, g++, libssl-dev.

$ sudo apt-get install gcc make g++ libssl-dev

Create mosquitto user and group.

$ sudo groupadd mosquitto
$ sudo useradd -g mosuqitto mosquiotto

Compile mosquitto

Download souce code from here. http://mosquitto.org/download/

Extract tar ball and change directory.

$ tar xvzf mosquitto-1.2.3.tar.gz
$ cd mosquitto-1.2.3

Complile mosquitto.

$ make
$ sudo make install

Here are default intall path.

path files
/usr/local/sbin mosquiotto server
/etc/mosquitto configuration
/usr/local/bin utility command

Sample configuration file will be installed in /etc/mosquitto/mosquitto.conf.example. Change file name to be official.

$ mv /etc/mosquitto/mosquitto.conf.example /etc/mosquitto/mosquitto.conf

Start mosquitto

Boot mosquitto by following command.

$ sudo -c mosquitto /usr/local/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf

If you want to start mosquitto in background, please add -d option in order to start it as daemon.

Upstart

Upstart is available on Ubuntu by default. Add mosquitto.conf to /etc/init/.

/etc/init/mosquitto.conf
description “Mosquitto MQTT broker”
author “Roger Light <roger@atchoo.org>”

start on net-device-up

respawn

exec /usr/local/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf

Register the script.

$ sudo initctl reload-configuration
$ sudo initctl list | grep mosquitto

Please make sure mosquitto is registered.

You can start/stop mosquitto as follows:

$ sudo initctl (start|stop) mosquitto

If the configuration is registerd correctly, mosquitto will be started automecally as of next boot.

1
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2