Post

Linux에 Mosquitto 설치

1. 계정 추가

1
2
[root@localhost ~]# useradd mosquitto
[root@localhost ~]# groupadd mosquitto

2. 의존성 패키지 설치

1
2
3
4
5
[root@localhost openssl]# make
[root@localhost openssl]# make install
[root@localhost openssl]# make clean
[root@localhost openssl]# unset LDFLAGS
[root@localhost openssl]# unset CPPFLAGS

3. OpenSSL 설치

1) 다운로드

1
2
3
4
5
6
7
8
9
[root@localhost ~]# wget https://www.openssl.org/source/openssl-1.1.1g.tar.gz
[root@localhost ~]# tar -zxvf openssl-1.1.1g.tar.gz
[root@localhost ~]# cp -Rf openssl-1.1.1g /usr/local/openssl
[root@localhost ~]# cd /usr/local/openssl
 
[root@localhost openssl]# export LDFLAGS=-L/usr/local/lib
[root@localhost openssl]# export CPPFLAGS=-I/usr/local/include
[root@localhost openssl]# make clean
[root@localhost openssl]# ./config --prefix=/usr --openssldir=/usr/local/openssl shared threads zlib

2) 설치

1
2
3
4
5
[root@localhost openssl]# make
[root@localhost openssl]# make install
[root@localhost openssl]# make clean
[root@localhost openssl]# unset LDFLAGS
[root@localhost openssl]# unset CPPFLAGS

3) 라이브러리 로딩 추가

  • 편집
1
[root@localhost ~]# vi /etc/ld.so.conf
  • 추가
1
2
include ld.so.conf.d/*.conf
include /usr/local/openssl/lib
  • 적용
1
[root@localhost ~]# /sbin/ldconfig

4) 설치 확인

1
[root@localhost ~]# openssl version

4. Mosquitto 설치

1) 다운로드

1
2
3
4
[root@localhost ~]# wget https://mosquitto.org/files/source/mosquitto-1.6.12.tar.gz
[root@localhost ~]# tar -zxvf mosquitto-1.6.12.tar.gz
[root@localhost ~]# cp -Rf mosquitto-1.6.12 /usr/local/mosquitto
[root@localhost ~]# cd /usr/local/mosquitto

2) 설치

1
2
[root@localhost mosquitto]# make
[root@localhost mosquitto]# make install

3) 라이브러리 로딩 추가

  • 편집
1
[root@localhost ~]# vi /etc/ld.so.conf
  • 추가
1
include /usr/local/mosquitto/lib
  • 적용
1
[root@localhost ~]# /sbin/ldconfig
  • ld.so.conf 내용
1
2
3
4
5
include ld.so.conf.d/*.conf
include /usr/local/openssl/lib
include /usr/local/mosquitto/lib
/usr/lib
/usr/local/lib

4) 심볼릭 링크 생성

1
[root@localhost ~]# ln -s /usr/local/mosquitto/lib/libmosquitto.so.1 /usr/lib/libmosquitto.so.1

5) MOSQUITTO_HOME 설정

  • 편집
1
[root@localhost ~]# vi /etc/profile
  • 추가
1
2
3
4
MOSQUITTO_HOME=/usr/local/mosquitto
export MOSQUITTO_HOME
PATH=$PATH:$MOSQUITTO_HOME/src
export PATH
  • 적용
1
[root@localhost ~]# source /etc/profile

6) Port 열기

1
2
3
[root@localhost ~]# iptables -I INPUT -m tcp -p tcp --dport 1883 -j ACCEPT
[root@localhost ~]# /sbin/service iptables save
[root@localhost ~]# /sbin/service iptables restart

7) Broker 실행

1
2
3
[root@localhost mosquitto]# mosquitto
# OR
[root@localhost mosquitto]# mosquitto -c ./mosquitto.conf -v

[출처 및 참고]

This post is licensed under CC BY 4.0 by the author.