centos6 5 mqtt安裝

2022-09-23 10:27:10 字數 1349 閱讀 3149

所需安裝包:

libwebsockets-v1.6-stable.tar.gz,mosquitto-1.4.8.tar.gz

# yum -y install gcc gcc-c++ openssl-devel  c-ares-devel libuuid-devel wget cmake

# cd libwebsockets-v1.6-stable

# mkdir bulid

# cd bulid

# cmake ..

# make && make install

# cd /mosquitto-1.4.8

儲存後,執行

# ln -s /usr/local/lib/libwebsockets.so.6 /usr/lib64/libwebsockets.so.6

# groupadd mosquitto

# useradd -g mosquitto mosquitto

# cd /etc/mosquitto/

如果該目錄下沒有mosquitto.conf 和 pwfile

,執行# cp mosquitto.conf.example mosquitto.conf

# cp pwfile.example pwfile

並在檔案最後加入

# mosquitto -c /etc/mosquitto/mosquitto.conf

需要開啟2個視窗

訂閱:

傳送訊息:

如果訂閱視窗列印出hello world ,證明mqtt安裝成功。

在安裝過程中,或測試過程中可能會遇到錯誤:

mosquitto_sub: error while loading shared libraries: libmosquitto.so.1: cannot open shared object file: no such file or directory

解決方法:

# cat /etc/ld.so.conf

# echo "/usr/local/lib">>/etc/ld.so.conf

# ldconfig