美文网首页物联网之家
Ubuntu部署EMQ与调试

Ubuntu部署EMQ与调试

作者: tarscoding | 来源:发表于2018-09-06 17:29 被阅读1次

    最近的项目在做IOT:
    硬件上云篇

    这是服务器篇:
    1.使用的协议是 MQTT,
    2.采用的实现方案是国产开源EMQ代理器
    下面简单记录一下emq服务端部署需要注意的细节:
    1.下载解压EMQ

    wget http://emqtt.com/downloads/2318/ubuntu16_04
    

    2.解压并进入目录

    unzip emqtt && cd emqtt
    

    3.启动emq

    ./bin/emqttd start
    

    4.查看状态

    ./bin/emqttd_ctl status
    

    5.控制台地址是127.0.0.1:18083


    image.png

    6.ngxin端口转发到80地址,ngxin配置文件

    server
    {
            listen 80;
            server_name emqtt.your-domain.com ; #你的子域名
    
            location /
            {
            proxy_redirect off;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_pass http://127.0.0.1:18083;
            }
    
            location ~ .*\.(php|jsp|cgi|asp|aspx|flv|swf|xml)?$
            {
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-For $remote_addr;
            proxy_pass http://127.0.0.1:18083;
    
            }
    
            access_log off;
    }
    

    7.部署在阿里云上有一个细节需要注意的就是
    端口的开启,

    8.查看端口开启

    netstat  -an
    

    查看防火墙开启端口

    #阿里云Ubuntu基本上使用iptables,所以先找到iptables
    sudo whereis iptables
    #列出端口
    /sbin/iptables -L
    

    如图


    image.png

    9.配置文件在如图 /etc/iptables/rules中
    在其中添加需要开启的端口


    image.png

    10.保存文件

    /sbin/iptables save
    

    11.nginx域名转发一下端口

    12.重启nginx服务

    13.浏览器访问

    相关文章

      网友评论

        本文标题:Ubuntu部署EMQ与调试

        本文链接:https://www.haomeiwen.com/subject/qxixgftx.html