周末弄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. Mac安装brew(遇到的坑)

    1.安装方法: 网上都会有 命令行输入 /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/i ...

  2. atom插件安装失败解决方法

    在atom 上下载插件失败,可以用下面的方法. 1.找到C:/Users/你的用户名/.atom/packages/文件夹内 2.在.atom packages 目录下 使用gitbash 3.git ...

  3. [Leetcode 78]求子集 Subset

    [题目] Given a set of distinct integers, nums, return all possible subsets (the power set). Note: The ...

  4. Android开发 ---基本UI组件4:拖动事件、评分进度条、圆圈式进度条、进度条控制

    Android开发 ---基本UI组件4 1.activity_main.xml 描述: 定义了一个按钮 <?xml version="1.0" encoding=" ...

  5. 一篇提及如何通过串口读取并提取GPS信号的论文

    一篇提及如何通过串口读取并提取GPS信号的论文 作者:崔杰 梁计春 王国军 目前,在用计算机进行数据传输时,常用的是串行通信方式.在Visual C++的编程中,既可以用Windows API函数进行 ...

  6. split根据一个元素分割语句

    a = ‘https://www.baidu.com/s?wd=%E7%AE%80%E4%B9%A6&rsv_spt=1&rsv_iqid=0xdfa3666f00083a6f& ...

  7. Python 管道

    from multiprocessing import Process,Pipe def f1(conn): from_zhujincheng = conn.recv() print("我是 ...

  8. 获取map集合中key、value

    获取Map集合类中key.value的两种方法 方法一:利用Set集合中的keySet()方法 Map<String,String> map = new HashMap<String ...

  9. 用rz、sz命令在Xshell传输文件

    用rz.sz命令在Xshell传输文件 2014-03-27 14:38:17 标签:用rz.sz命令在Xshell传输文件 Xshell很好用,然后有时候想在windows和linux之间上传或下载 ...

  10. “必须执行Init_Clk函数,才能采集到二氧化碳接口485数据的问题”的解决

    这个问题困扰了我很长一段时间,而且如果这个问题不解决,就有一个无法调和的矛盾:执行Init_Clk函数,能采集到二氧化碳接口485数据,但是功耗大:不执行Init_Clk函数,不能采集到二氧化碳接口4 ...