在Linux (Red Hat) 中 安装Opnefire 教程

我们将使用 Postgresql 数据库在 Red hat Linux 6.2 中逐步安装 openfire

确保你的机器上安装了 postgresql 数据库和 openfire rpm软件包

可以从openfire官网获取openfire rpm包
http://www.igniterealtime.org/downloads/

安装准备工作

为 Postgresql 数据库安装以下软件包
postgresql-server-8.4.13-1.el6_3.i686
postgresql-libs-8.4.13-1.el6_3.i686
postgresql-8.4.13-1.el6_3.i686

# yum install postgresql postgresql-server postgresql-libs

安装 openfire rpm

# rpm -ivh openfire-3.8.2-1.i386.rpm

为 openfire 配置 postgresql 数据库

现在,只要我们安装了 postgresql 的 rpm 文件,就会默认创建一个用户“postgres”,我们可以使用以下命令进行验证

# cat /etc/passwd | grep postgres
postgres:x:26:26:PostgreSQL Server:/var/lib/pgsql:/bin/bash

从输出可以看到,用户 postgres 的默认值是

主目录:/var/lib/pgsql
默认shell:/bin/bash
默认密码:无

我们需要使用以下命令手动为用户“postgres”分配密码

# passwd postgres

在启动服务数据库之前必须进行初始化。
以 postgres 用户身份登录

# su - postgres
-bash-4.1$initdb --pgdata=/var/lib/pgsql/data
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
The database cluster will be initialized with locale en_US.UTF-8.
The default database encoding has accordingly been set to UTF8.
The default text search configuration will be set to "english".

creating directory /var/lib/pgsql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 32MB
creating configuration files ... ok
creating template1 database in /var/lib/pgsql/data/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the -A option the
next time you run initdb.

Success. You can now start the database server using:

    postgres -D /var/lib/pgsql/data
or
    pg_ctl -D /var/lib/pgsql/data -l logfile start 

完成数据库初始化后,以 root 身份启动 postgresql 服务

$su - root
# /etc/init.d/postgresql start
Starting postgresql service:                              

[  OK  ]

为 openfire 创建用户和数据库

# useradd jack 
# passwd jack

为用户“jack”分配密码

现在以 postgres 用户身份登录

# su - postgres
-bash-4.1$createdb openfire
-bash-4.1$psql openfire
psql (8.4.13)
Type "help" for help.
openfire=#
CREATE USER jack WITH PASSWORD 'example123';
CREATE ROLE
openfire=# GRANT ALL PRIVILEGES ON DATABASE openfire to jack;
GRANT

现在从命令行验证我们是否可以使用用户 jack 登录 openfire 数据库。
从 postgres 控制台退出

openfire=# q

以 jack 身份登录

-bash-4.1$su - jack
Password:
[jack@test ~]$psql -d openfire -U jack
psql (8.4.13)
Type "help" for help.

openfire=>

因此,我们已成功使用 jack 用户连接到我们的数据库。

配置 openfire

注意:在本教程中,我禁用了防火墙和 selinux。

使用 GUI 在客户端计算机或者本地主机上打开浏览器,然后转到下面提到的 url

http://(your_machine_ip):9090

单击完成完成设置。

现在转到 openfire 服务器的 CLI 以启动聊天服务

# cd /opt/openfire/bin
# ./openfire.sh 

Openfire 3.8.2 [Sep 21, 2013 6:09:18 PM] 
Admin console listening at: 
 http://10.10.20.26:9090
 https://10.10.20.26:9091 

注意:请确保我们不要关闭此终端,因为它会关闭聊天服务器正在运行的服务

日期:2020-06-02 22:18:36 来源:oir作者:oir