Dockerfile制作mosquitto镜像
一、安装依赖包
yum install gcc gcc-c++ cmake make openssl-devel libxslt docbook-style-xsl -y
二、安装websocket
1.安装
软件版本:libwebsockets-4.0.1
tar xvf libwebsockets-4.0.1.tar.gz -C /opt
cd /opt/libwebsockets-4.0.1
mkdir build
cd build
cmake ..
make && make install
2.配置libwebsockets的头文件和库文件的路径到环境变量
cat >> /etc/profile << EOF
export WEBSOCKET_HEADER=/usr/local/include
export WEBSOCKET_LIB=/usr/local/lib
export PATH=$PATH:$WEBSOCKET_HEADER:$WEBSOCKET_LIB
EOF
source /etc/profile
三、安装mosquitto
软件版本:mosquitto-1.6.7
wget https://mosquitto.org/files/source/mosquitto-1.6.7.tar.gz --no-check-certificate
tar xvf mosquitto-1.6.7.tar.gz -C /opt
cd /opt/mosquitto-1.6.7
make && make install
mosquitto -v #查看版本
四、make install报错解决
参考文章:https://blog.csdn.net/houjixin/article/details/46711547
mosquitto -v报错
解决方法:
把宿主机的libssl.so.1.0.0和libcrypto.so.1.0.0拷贝到容器的/usr/local/lib/下,执行
ln -s /usr/local/lib/libssl.so.1.0.0 /usr/lib/libssl.so.1.0.0
ln -s /usr/local/lib/libcrypto.so.1.0.0 /usr/lib/libcrypto.so.1.0.0
ldconfig
五、修改配置文件
cp mosquitto.conf mosquitto.conf.bak
vim mosquitto.conf
user root
log_dest file /var/log/mosquitto.log
mosquitto -c mosquitto.conf -d #放后台运行
ss -nutlp |grep mosquit
参考文章:https://blog.csdn.net/FreeApe/article/details/85261543