#
源码编译 cmake
1
2
3
4
5
6
7
8
9
10
11
12
|
yum -y install wget git gcc gcc-c++ openssl-devel
wget https://github.com/Kitware/CMake/releases/download/v3.24.2/cmake-3.24.2.tar.gz
tar zxvf cmake-3.24.2.tar.gz
cd cmake-3.24.2
./bootstrap --prefix=/usr/local/cmake
make && make install
sudo ln -s /usr/local/cmake/bin/cmake /usr/bin/cmake
|
#
源码编译libwebsockets
高于v2.4.2 LWS_WITH_EXTERNAL_POLL默认关闭需要开启
1
2
3
4
5
6
7
8
9
10
11
12
13
|
git clone https://libwebsockets.org/repo/libwebsockets
cd libwebsockets
git checkout v4.3-stable
mkdir build
cd build
cmake \
-DLWS_WITH_EXTERNAL_POLL=ON \
-DLWS_WITH_HTTP2=ON \
-DLWS_WITHOUT_TESTAPPS=ON \
-DLWS_UNIX_SOCK=ON \
-DLWS_IPV6=ON \
../
make && make install
|
#
源码编译 mosquitto
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
##下载 mosquitto
wget https://mosquitto.org/files/source/mosquitto-2.0.15.tar.gz
tar zxvf mosquitto-2.0.15.tar.gz
cd mosquitto-2.0.15
##开启websocket
vi config.mk
WITH_WEBSOCKETS:=yes
mkdir build
cd build
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local \
-DOPENSSL_ROOT_DIR=/usr/local \
-DWITH_WEBSOCKETS=OFF \
-DDOCUMENTATION=OFF \
-DCMAKE_C_FLAGS="-I/usr/local/include" \
-DCMAKE_EXE_LINKER_FLAGS="-L/usr/local/lib" \
../
make WITH_WEBSOCKETS=yes && make install
cp service/systemd/mosquitto.service.simple /usr/lib/systemd/system/mosquitto.service
vi /usr/lib/systemd/system/mosquitto.service
ExecStart=/usr/local/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
mv /usr/local/etc/mosquitto /etc/mosquitto
## 添加mosquitto用户组合用户 或者修改配置文件 mosquitto.conf 将user mosquitto哪一行配置改成user root
sudo groupadd mosquitto
sudo useradd -g mosquitto mosquitto
## 配置文件mosquitto.conf
listener 1883 0.0.0.0
protocol mqtt
listener 1884 0.0.0.0
protocol websockets
socket_domain ipv4
## 开机自启动
systemctl enable mosquitto.service
systemctl start mosquitto.service
## 开启防火墙端口
firewall-cmd --zone=public --add-port=1883/tcp --permanent
firewall-cmd --zone=public --add-port=1884/tcp --permanent
firewall-cmd --reload
|