周末弄wordpress的Mysql,一不小心把wordpress弄不好了,写了的好几遍文章也没有了,一怒之下,把整个系统重装了,安装了不带任何软件的新系统,重新搭一遍。

0.安装ftp服务器

#yum install vsftpd
#service vsftpd restart

1.安装编译工具

#yum install gcc gcc-c++
#yum install cmake

2.安装mosquitto编译时需要的依赖库

#yum install openssl-devel
#yum install c-ares-devel
#yum install libuuid-devel

3.安装websocket库

mosquitto支持websocket,需要安装websocket库文件。

websocket下载网址https://libwebsockets.org/下载之后,用ftp工具传到centos,解压编译。

#tar -vxf libwebsockets-2.3.0.tar.gz
#cd libwebsockets-2.3.0
#mkdir build
#cd build
#cmake ..
#make
#make install

4.mosquitto下载安装和配置

mosquitto下载地址:http://mosquitto.org/files/source/用ftp工具传到centos,解压配置编译安装。

#tar -vxf mosquitto-1.4.14.tar.gz
#cd mosquitto-1.4.14.tar.gz

修改config.mk文件以使后面编译的mosquitto文件支持websocket。

WITH_WEBSOCKETS:=yes

#make
#make install

修改配置文件,将/etc/mosquitto/下的mosquitto.conf.example重命名为mosquitto.conf来修改一下,

#mv /etc/mosquitto/mosquitto.conf.example /etc/mosquitto/mosquitto.conf
#vim /etc/mosquitto/mosquitto.conf
修改如下:
port 1883
listener 9001
protocol websockets

5.运行测试

启动服务,一般会报错,

# mosquitto -c /etc/mosquitto/mosquitto.conf -d
mosquitto: error while loading shared libraries: libwebsockets.so.11: cannot open shared object file: No such file or directory

是程序执行时找不到libwebsockets的库文件,执行下面的命令为库做一下符号连接,如果出现其他库找不到,也链接一下。

#ln -s /usr/local/lib/libwebsockets.so.11 /usr/lib64/libwebsockets.so.11

再次运行,如果出现Error: Invalid user ‘mosquitto’错误,使用adduser mosquitto添加用户。

订阅,打开另一个终端窗口,运行:

#mosquitto_sub -t topic

打开另一个终端窗口发布主题:

[root@iZjafzbmqur2lzZ ~]# mosquitto_sub -t topic
hello world
hello world
hello world
hello world
hello world

  

mosquitto centos安装配置的更多相关文章

  1. 阿里云服务器Linux CentOS安装配置(零)目录

    阿里云服务器Linux CentOS安装配置(零)目录 阿里云服务器Linux CentOS安装配置(一)购买阿里云服务器 阿里云服务器Linux CentOS安装配置(二)yum安装svn 阿里云服 ...

  2. 阿里云服务器Linux CentOS安装配置(九)shell编译、打包、部署

    阿里云服务器Linux CentOS安装配置(九)shell编译.打包.部署 1.查询当前目录以及子目录下所有的java文件,并显示查询结果 find . -name *.java -type f - ...

  3. 阿里云服务器Linux CentOS安装配置(八)nginx安装、配置、域名绑定

    阿里云服务器Linux CentOS安装配置(八)nginx安装.配置.域名绑定 1.安装nginx yum -y install nginx 2.启动nginx service nginx star ...

  4. 阿里云服务器Linux CentOS安装配置(七)域名解析

    阿里云服务器Linux CentOS安装配置(七)域名解析 1.购买域名 登录阿里云,左侧菜单点击[域名],然后[域名注册],完成域名购买.(一般首年45元) 2.添加域名解析 在域名列表里点击你的域 ...

  5. 阿里云服务器Linux CentOS安装配置(六)resin多端口配置、安装、部署

    阿里云服务器Linux CentOS安装配置(六)resin多端口配置.安装.部署 1.下载resin包 http://125.39.66.162/files/2183000003E08525/cau ...

  6. 阿里云服务器Linux CentOS安装配置(五)jetty配置、部署

    阿里云服务器Linux CentOS安装配置(五)jetty配置.部署 1.官网下载jetty:wget http://repo1.maven.org/maven2/org/eclipse/jetty ...

  7. 阿里云服务器Linux CentOS安装配置(四)yum安装tomcat

    阿里云服务器Linux CentOS安装配置(四)yum安装tomcat 1.yum -y install tomcat  执行命令后,会帮你把jdk也安装好 2.tomcat安装目录:/var/li ...

  8. 阿里云服务器Linux CentOS安装配置(三)yum安装mysql

    阿里云服务器Linux CentOS安装配置(三)yum安装mysql 1.执行yum安装mysql命令:yum -y install mysql-server mysql-devel 2.启动mys ...

  9. 阿里云服务器Linux CentOS安装配置(二)yum安装svn

    阿里云服务器Linux CentOS安装配置(二)yum安装svn 1.secureCRT连接服务器 2.先创建一个文件夹,用来按自己的习惯来,用来存放数据 mkdir /data 3.yum安装sv ...

随机推荐

  1. 机器学习 之LightGBM算法

    目录 1.基本知识点简介 2.LightGBM轻量级提升学习方法 2.1 leaf-wise分裂策略 2.2 基于直方图的排序算法 2.3 支持类别特征和高效并行处理 1.基本知识点简介 在集成学习的 ...

  2. Electron "jQuery/$ is not defined" 解决方法

    参考问题:https://stackoverflow.com/questions/32621988/electron-jquery-is-not-defined <!-- Insert this ...

  3. 兼容 Spring Boot 1.x 和 2.x 配置类参数绑定的工具类 SpringBootBindUtil

    为了让我提供的通用 Mapper 的 boot-starter 同时兼容 Spring Boot 1.x 和 2.x,增加了这么一个工具类. 在 Spring Boot 中,能够直接注入 XXProp ...

  4. Android开发 ---基本UI组件8:九宫格布局、setOnItemClickListener()项被选中监听事件

    效果图: 1.activity_main.xml 描述: 定义了一个按钮 <?xml version="1.0" encoding="utf-8"?> ...

  5. 划分树(poj2104)

    poj2104 题意:给出n个数,有m次查询,每次查询要你找出 l 到 r 中第 k 大的数: 思路:划分树模板题 上述图片展现了查询时如何往下递推的过程 其中ly表示 [sl,l) 中有多少个数进入 ...

  6. jmeter接口测试基础知识1.0

    jmeter:性能测试工具,压测测试计划右键--添加--Threads(Users)--线程组(线程数就是并发数)--右键线程组--添加--Sampler--HTTP请求--最上面的名称可以修改,就是 ...

  7. js 异常判断

    /** * 预处理response * @param rep */ function validateRep(rep) { try{ if(rep.status==false){ layer.open ...

  8. 利用Java获取ip地址

    方法1 public static String getIp2(HttpServletRequest request) { String ip = request.getHeader("X- ...

  9. [转]Spark学习之路 (三)Spark之RDD

    Spark学习之路 (三)Spark之RDD   https://www.cnblogs.com/qingyunzong/p/8899715.html 目录 一.RDD的概述 1.1 什么是RDD? ...

  10. Spring Cloud 请求重试机制核心代码分析

    场景 发布微服务的操作一般都是打完新代码的包,kill掉在跑的应用,替换新的包,启动. spring cloud 中使用eureka为注册中心,它是允许服务列表数据的延迟性的,就是说即使应用已经不在服 ...