Ubuntu18.04虚拟机MQTT服务器(1)——安装宝塔服务器面板与MQTT服务器

1 虚拟机安装ubuntu18.04

使用VMware安装Ubuntu 18.04 64位系统。

2 Ubuntu修改镜像源

在Software & Update内修改镜像源为清华源。
更新。

3 安装ssh

输入以下命令,安装远程连接工具。

sudo apt install openssh-client
sudo apt install openssh-server

4 安装宝塔服务器面板

1、输入以下命令下载并安装宝塔:

wget -O install.sh https://download.bt.cn/install/install-ubuntu_6.0.sh && sudo bash install.sh ed8484bec

安装完毕会生成以下信息:(每个人都不一样)

外网面板地址: https://223.67.114.514:8888/123456789
内网面板地址: https://192.168.114.514:8888/123456789
username:114514
password:114514

2、安装Linux下的网络扫描和嗅探工具nmap:

sudo apt-get install nmap

输入命令,看到有端口22就行了:

nmap 127.0.0.1

3、点击虚拟机内浏览器进入内网面板地址,安装LAMP(Linux + Apache + MySQL+php)或LNMP(Linux + Nginx + MySQL+php),Apache更安全,Nginx消耗资源更少。

4、关闭防火墙:

sudo ufw status
sudo ufw disable

5、宝塔关闭后如何启动宝塔:

sudo /etc/init.d/bt default

5 安装MQTT服务器:EMQX 4.4.18 for Docker

1、安装Docker :
https://blog.csdn.net/wblylh/article/details/127471316
https://blog.csdn.net/yushuir/article/details/115142105

wget https://www.emqx.io/downloads/broker/v4.2.8/emqx-ubuntu18.04-4.2.8-x86_64.deb			#下载
sudo apt install ./emqx-ubuntu18.04-4.2.8-x86_64.deb			#安装
sudo emqx start				#启动

2、用户名:admin 密码:public
3、宝塔-安全里面添加端口规则,对MQTT的端口18083、8083放行。
4、使用浏览器打开EMQX服务器控制面板,输入以下网址:

http://虚拟机ip地址/18083/

5、不知道虚拟机ip地址可以安装以下工具:

sudo apt install net-tools
ifconfig					# 查询ip地址

6 MQTT服务器的WebSocket和MQTT.fx联合测试

https://blog.csdn.net/youngwah292/article/details/127941436

1、WebSocket试验:
主机浏览器和虚拟机浏览器都进入MQTT服务器面板网址,点击工具,WebSocket,连接。
在这里插入图片描述
主机和虚拟机都点击订阅,主机上发布消息,虚拟机可以显示消息内容。
主机WebSocket:
主机
虚拟机WebSocket:
在这里插入图片描述

参考:https://blog.csdn.net/weixin_42753193/article/details/127895446

猜你喜欢

转载自blog.csdn.net/qq_45362336/article/details/130604049