1.centos7安装mosquitto
yum -y install gcc gcc-c++ libstdc++-devel
yum -y install openssl-devel
yum -y install c-ares-devel
yum -y install uuid-devel
yum -y install libuuid-devel
2.下载包下载
3.解压安装
tar -zxvf mosquitto-1.6.7.tar.gz #要根据自己下载的来解压
cd mosquitto-1.6.7/ #进入mosquitto文件夹
make && make install #安装
cd /etc/mosquitto/ #进入目录
cp mosquitto.conf.example mosquitto.conf #拷贝并改名
4.新建用户并启动
adduser mosquitto #新增用户:mosquitto
mosquitto -c /etc/mosquitto/mosquitto.conf #启动mosquitto
因为之前1883端口是emqx,未关,emqx关掉后重新打开
编译问题解决
如果出现error while loading shared libraries: libmosquitto.so.1: cannot open shared object file: No such file or directory
//创建链接
$ sudo ln -s /usr/local/lib/libmosquitto.so.1 /usr/lib/libmosquitto.so.1
//更新链接
$ sudo ldconfig