Build mqtt service on centos, mainly used mosquitto news agency services software:
My linux version centos7
1, install the software
Installation in accordance with the following command:
install gcc-c ++ yum
yum install cmake
yum install OpenSSL-devel
new data in folders software download mosquitto version, and unzip command is as follows:
mkdir data
cd data
wget http://mosquitto.org/files/source/mosquitto-1.4.10.tar.gz
tar -xzvf mosquitto-1.4.10.tar.gz
Installation c-areas:
wget http://c-ares.haxx.se/download/c-ares-1.10.0.tar.gz
tar xvf c-ares-1.10.0.tar.gz
cd c-ares-1.10.0
./configure
make
sudo make install
Installation lib-uuid:
yum install libuuid-devel
Installation libwebsockets:
https://github.com/warmcat/libwebsockets/archive/v1.3-chrome37-firefox30.tar.gz wget
the tar-firefox30.tar.gz chrome37 zxvf V1.3-
CD-1.3-chrome37 libwebsockets-firefox30
mkdir Build
CD Build
CMake = 64 .. -DLIB_SUFFIX
the make the install
above may not have a successful installation, especially the third, but did not cause illness, but there is no corresponding function
We modify the configuration of mosquitto:
1.4.10 mosquitto-CD
Vim the config.mk
the inside WITH_SRV: = yes and WITH_UUID: = yes are commented with a No. #
Then compile and install mosquitto:
make
sudo make install
2, start the test
Create a user:
groupadd mosquitto sudo
sudo useradd -g mosquitto mosquitto
If there is anything here that does not exist the problem, you must copy the wrong
Configuration:
mv /etc/mosquitto/mosquitto.conf.example /etc/mosquitto/mosquitto.conf
start the program:
mosquitto -c /etc/mosquitto/mosquitto.conf -d
default port 1883
Finally, we'll open a window server, in a (subscription) window type:
mosquitto_sub -t hello
to another (release) window enter:
mosquitto_pub the Hello -h localhost -t -m "the Hello world!"
program screenshots:
Note : If prompted to find libmosquitto.so.1 in mosquitto_sub -t hello, then enter the following command to change it the next libmosquitto.so position:
sudo ln -s /usr/local/lib/libmosquitto.so.1 /usr/lib/libmosquitto.so.1
sudo ldconfig
In this way, we have successfully subscribed to the theme of the hello message, as shown:
Original link: https: //blog.csdn.net/weixin_41656968/article/details/80159589