---
title: "mosquitto编译安装笔记"
author: "兰迪RANDY"
date: "2014-07-07T15:19:05Z"
tags: []
categories: ["开源软件"]
slug: "mosquitto"
draft: false
lastmod: "2014-07-07T15:19:05Z"
id: 2089114
url: "https://hmw.iteye.com/blog/2089114"
---

wget http://mosquitto.org/files/source/mosquitto-1.3.1.tar.gz

tar zxf mosquitto-1.3.1.tar.gz

cd mosquitto-1.3.1

vim config.mk

把WITH_SRV:=yes注释掉


创建配置文件，使用默认配置

cp /etc/mosquitto/mosquitto.conf.example /etc/mosquitto/mosquitto.conf

vim /etc/mosquitto/mosquitto.conf

修改：

password_file /etc/mosquitto/pwfile

创建一个test用户：

/usr/local/mosquitto/bin/mosquitto_passwd -c /etc/mosquitto/pwfile test

输入两次密码即可

添加用户：

#/usr/local/mosquitto/bin/mosquitto_passwd -u /etc/mosquitto/pwfile test2


创建linux上的mosquitto用户（默认使用该用户启动）

useradd -s /sbin/nologin mosquitto


启动服务

/usr/local/mosquitto/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf -d