云网牛站
所在位置:首页 > Linux云服务器 > 在Ubuntu 18.04/16.04上安装Openfire XMPP chat server的方法

在Ubuntu 18.04/16.04上安装Openfire XMPP chat server的方法

2019-02-09 11:04:32作者:戴进稿源:云网牛站

本文介绍在Ubuntu 18.04、Ubuntu 16.04系统上安装Openfire XMPP chat server(Openfire XMPP聊天服务器)的方法。Openfire是一种利用XMPP/Jabber协议的流行且功能强大的即时消息(IM)服务器, Openfire还具有体面的Presence Server的所有功能。

 

一、更新系统包

确保Ubuntu 18.04系统上的所有软件包都是最新的,运行以下命令:

$ sudo apt-get update

$ sudo apt-get upgrade

 

二、安装JAVA JDK

更新软件包后,如果你愿意,请安装openjdk-8-jdk或9,openjdk-8-jdk包可以在Ubuntu官方存储库中找到,通过运行命令进行安装:

$ sudo apt-get install openjdk-8-jdk

$ java -version

openjdk version "1.8.0_171"

OpenJDK Runtime Environment (build 1.8.0_171-8u171-b11-0ubuntu0.18.04.1-b11)

OpenJDK 64-Bit Server VM (build 25.171-b11, mixed mode)

 

三、安装数据库

你可以从支持的数据库服务器中选择数据库:MySQL/MariaDB或PostgreSQL,对于此设置,我们将安装MariaDB或MySQL,参考:

在Ubuntu 18.04系统上安装MariaDB 10.4的步骤

在Ubuntu 18.04/16.04命令行上安装MySQL 8.0.11的全过程

创建数据库用户:

$ mysql -u root -p

Enter password: 

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 5

Server version: 5.7.22-0ubuntu18.04.1 (Ubuntu)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create database openfire;

Query OK, 1 row affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON openfire.* TO openfire@localhost IDENTIFIED BY 'password123!';

Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

mysql> exit

Bye

稍后我们将导入Openfire数据库数据。

 

四、下载并安装Openfire

下载Openfire包,当前的版本是Openfire 4.3.2:

$ wget https://www.igniterealtime.org/downloads/download-landing.jsp?file=openfire/openfire_4.3.2_all.deb \

-O openfire.deb

我们现在安装它:

$ sudo  dpkg -i openfire.deb 

Selecting previously unselected package openfire.

(Reading database ... 76619 files and directories currently installed.)

Preparing to unpack openfire.deb ...

Unpacking openfire (4.3.2) ...

Setting up openfire (4.3.2) ...

adduser: Warning: The home directory `/var/lib/openfire' does not belong to the user you are currently creating.

Processing triggers for ureadahead (0.100.0-20) ...

Processing triggers for systemd (237-3ubuntu10) ...

检查申请状态:

$ systemctl status openfire

openfire.service - LSB: Start/stop openfire jabber server

Loaded: loaded (/etc/init.d/openfire; generated)

Active:

Docs: man:systemd-sysv-generator(8)

Tasks: 22 (limit: 1153)

CGroup: /system.slice/openfire.service

└─28050 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java -server -DopenfireHome=/usr/share/openfire -Dopenfire.lib.dir=/usr/share/openfire/lib -classpath /usr/sh

Feb 9 10:00:06 haproxy-01 systemd[1]: Starting LSB: Start/stop openfire jabber server...

Feb 9 10:00:06 haproxy-01 openfire[28035]: best java alternative in: /usr/lib/jvm/java-8-openjdk-amd64/jre

Feb 9 10:00:06 haproxy-01 openfire[28035]: Starting openfire: openfire.

Feb 9 10:00:06 haproxy-01 systemd[1]: Started LSB: Start/stop openfire jabber server.

导入Openfire数据库架构:

$ mysql -u root -p

Enter password: 

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 6

Server version: 5.7.22-0ubuntu18.04.1 (Ubuntu)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use openfire;

Database changed

mysql> source /usr/share/openfire/resources/database/openfire_mysql.sql;

mysql> show tables;

 

五、配置防火墙和访问Openfire UI

如果你有活动的防火墙服务,则需要允许Openfire端口,我的Ubuntu 18.04系统运行ufw:

$ sudo ufw enable

$ for i in 9090 9091 5222 7777; do 

sudo ufw allow $i; done

参考:在Ubuntu 18.04系统中使用UFW设置防火墙

要访问GUI,你将使用服务器的IP地址和端口9090:

http://<server-ip|domain>:9090

将获得Openfire配置窗口:

在Ubuntu 18.04/16.04上安装Openfire XMPP chat server的方法

选择默认语言,然后单击继续,在服务器设置窗口中,设置域并单击继续按钮:

在Ubuntu 18.04/16.04上安装Openfire XMPP chat server的方法

我们将使用以下配置参数:

数据库驱动程序预设:MySQL

JDBC驱动程序类:com.mysql.jdbc.Driver

数据库URL:jdbc:mysql://127.0.0.1/openfire?useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8

用户名:openfire

密码:password123!

在Ubuntu 18.04/16.04上安装Openfire XMPP chat server的方法

单击继续并使用配置文件设置上的默认选项,你可以稍后添加LDAP等外部身份验证机制:

在Ubuntu 18.04/16.04上安装Openfire XMPP chat server的方法

设置管理员用户邮箱地址和密码:

在Ubuntu 18.04/16.04上安装Openfire XMPP chat server的方法

单击继续完成配置,这个时候将出现登录页面,使用admin作为用户名登录并提供上面配置的密码:

在Ubuntu 18.04/16.04上安装Openfire XMPP chat server的方法

如果一切顺利,将出现Openfire管理界面:

在Ubuntu 18.04/16.04上安装Openfire XMPP chat server的方法

至此,配置安装Openfire全部完成。

 

相关主题

在Ubuntu18.04系统中配置多个版本的JDK以满足不同的需求

精选文章
热门文章