周末弄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. js基本类型存放和对象存放的区别(对象遍历)

    js的基本类型,对象类型的应用在初学的时候,需要自己加以明确,明确了数据类型,在使用过程中才能正确使用变量.如下两个例子是摘自初学时的笔记,为大家提供参考. 1.对象可以存放属性和方法,js基本类型不 ...

  2. mac 不小心把管理员改成了普通用户

    最近手贱,不小心把mbp仅有的管理员账号设置成了普通用户,想重新改回管理员,竟然需要用其他管理员账号去更改.简直 那个 啥 ~ 下面将提供创建一个新的管理员账号的方案 不仅适用于上述我出现的问题,也适 ...

  3. PAT 1073 Scientific Notation

    1073 Scientific Notation (20 分)   Scientific notation is the way that scientists easily handle very ...

  4. JS--reload 重新加载 true参数

    location.reload() 作用是用来重新加载当前显示的页面. 如果调用reload()时不传递参数,页面就会以最有效的方式重新加载. 也就是说,如果页面自上次请求以来并没有改变过,页面就会从 ...

  5. Vim 安装、配置及复制粘贴操作

    1.安装:sudo apt-get install vim 2.配置:cd ~ #进入用户主目录 touch .vimrc #.后缀文件不可见 vi .vimrc #打开文件 输入: set cind ...

  6. 【转】python 中NumPy和Pandas工具包中的函数使用笔记(方便自己查找)

    二.常用库 1.NumPy NumPy是高性能科学计算和数据分析的基础包.部分功能如下: ndarray, 具有矢量算术运算和复杂广播能力的快速且节省空间的多维数组. 用于对整组数据进行快速运算的标准 ...

  7. centos6升级python

    CentOS 6中,默认安装了Python 2.6.而pip,jupyter这样的常用工具是不支持Python 2.6的.为了使用这些工具,就必须将Python 2.6升级到Python 2.7以上的 ...

  8. Julia安装以及使用扩展包package(ERROR: UndefVarError: Pkg not defined)

    刚刚安装好Julia1.0,想进行第一步尝试: Pkg.add("PyPlot") 却出现错误:ERROR: UndefVarError: Pkg not defined 问题描述 ...

  9. obspy下载地震波数据

    Retrieving Data from Data Centers(从数据中心检索数据) PS:此部分提供了使用obspy下载数据的推荐方式,但是由于数据中心和web服务在不断更新变化,所有有些建议可 ...

  10. angular2升级到angular4历程

    Angular 4 在昨天(2017-03-24)正式发布了,我的系列教程也得更新一下.步骤略繁琐,不用 cli 的项目反倒更简单一些,但是 cli 平时给我们的便利还是很多的,升级最多半年一次而已. ...