1.上传压缩包
2.解压压缩包
tar -zxvf mosquitto-2.0.18.tar.gz
3.编译
make && make install
3.1 问题
fatal error: openssl/opensslconf.h: No such file or directory
这是因为服务器缺少openssl组件
centos中运行yum install openssl-devel
ubuntu系统运行apt-get install libssl-dev
fatal error: cjson/cJSON.h: No such file or directory
缺少cjson依赖
git clone https://github.com/DaveGamble/cJSON.git
cd cJSON/
mkdir build
cd build/
cmake ..
make
make install
安装 cjson 过程中如果 提示 cmake: command not found
sudo yum install cmake
运行出现异常:Unable to drop privileges to 'mosquitto' because this user does not exist. Trying 'nobody' instead
需要给系统创建mosquitto用户和组
groupadd mosquitto
useradd -g mosquitto mosquitto
chown -R mosquitto:mosquitto /etc/mosquitto/
4.完成
安装成功会在 /etc/mosquitto
目录下面生成一下4个文件
install -m 644 mosquitto.conf "/etc/mosquitto/mosquitto.conf.example"
install -m 644 aclfile.example "/etc/mosquitto/aclfile.example"
install -m 644 pwfile.example "/etc/mosquitto/pwfile.example"
install -m 644 pskfile.example "/etc/mosquitto/pskfile.example"