Learn How To Setup an Openfire XMPP Server on CentOS 7

June 7, 2019

Table of Contents

If you are using a different system, please check our other tutorials.

Openfire is a free and open source XMPP server which is being widely deployed in enterprises and organizations to deliver real time collaborations.

In this article, I will guide you through installing Openfire on a CentOS 7 x64 server instance.

Prerequisites

  • A fresh IT Web Services CentOS 7 x64 server instance. Say its IP address is 203.0.113.1.
  • A sudo user.
  • https://www.itweb.services/tutorials/linux-guides/how-to-update-centos-7-ubuntu-16-04-and-debian-8″>updated to the latest stable status using the EPEL YUM repo.

  • The server instance’s hostname, domain name, and FQDN have been setup as openfire, example.com and openfire.example.com, respectively.

Download and install the latest Openfire x86_64 RPM package

On the official Openfire download page, find the direct download URL pointing to the latest stable release of Openfire x86_64 RPM package.

Next, use the following commands to download and rename the Openfire RPM package.

cd
wget -O openfire-4.2.2-1.x86_64.rpm https://www.igniterealtime.org/downloadServlet?filename=openfire/openfire-4.2.2-1.x86_64.rpm

With the help of the YUM package manager, you can easily install Openfire as follows. Be aware that the required JRE environment is bundled in this Openfire release, so you don’t need to setup Java by yourself.

sudo yum install openfire-4.2.2-1.x86_64.rpm -y

Openfire will be installed in the /opt/openfire directory.

Finally, start the Openfire service and make it automatically start on boot.

sudo systemctl start openfire.service
sudo systemctl enable openfire.service

Setup an external MariaDB database for Openfire

Openfire can work with an embedded database or an external database. In order to achieve better performance, you can setup an external database as described in this step. If the embedded database is OK with you, skip this step.

Install the latest stable release of MariaDB.

curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash
sudo yum install MariaDB-server MariaDB-client -y

Start the MariaDB service and make it automatically start on boot.

sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service

Secure the installation of MariaDB.

sudo /usr/bin/mysql_secure_installation

When prompted, answer questions as below:

  • Enter current password for root (enter for none): Just press ENTER
  • Set root password? [Y/n]: Y
  • New password: your-MariaDB-root-password
  • Re-enter new password: your-MariaDB-root-password
  • Remove anonymous users? [Y/n]: Y
  • Disallow root login remotely? [Y/n]: Y
  • Remove test database and access to it? [Y/n]: Y
  • Reload privilege tables now? [Y/n]: Y

Create a dedicated database for Openfire using the MySQL shell.

mysql -u root -p

In the MySQL shell, use the following commands to create a database, openfire, a database user, openfireuser, and its password, yourpassword.

CREATE DATABASE openfire;
CREATE USER 'openfireuser'@'localhost' IDENTIFIED BY 'yourpassword';
GRANT ALL PRIVILEGES ON openfire.* TO 'openfireuser'@'localhost' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;

Setup the Openfire XMPP server

Before you can setup the Openfire XMPP server on its web interface, you need to open the port 9090 by modifying firewall rules.

sudo firewall-cmd --zone=public --permanent --add-port=9090/tcp
sudo firewall-cmd --reload

Next, point your browser to http://203.0.113.1:9090 to start the setup process.

On the “Welcome to Setup” page, choose your language and then click the “Continue” button.

On the “Server Settings” page, input the XMPP domain name example.com and the server host name (FQDN) openfire.example.com, leaving other fields untouched, and then click the “Continue” button.

On the “Database Settings” page, choose the “Standard Database Connection” option and then click the “Continue” button.

On the “Database Settings - Standard Connection” page, input settings as follows, leaving other options untouched, and then click the “Continue” button.

  • Database Driver Presets: MySQL
  • JDBC Driver Class: com.mysql.jdbc.Driver
  • Database URL: jdbc:mysql://localhost:3306/openfire?rewriteBatchedStatements=true
  • Username: openfireuser
  • Password: yourpassword

On the “Profile Settings” page, choose the “Default” option, and then click the “Continue” button.

On the “Administrator Account” page, input the admin email address admin@example.com and a new password twice, and then click the “Continue” button. If you click the “Skip This Step” button, you will have to use the default password admin.

On the “Setup Complete!” page, click the “Login to the admin console” button to finish the setup and jump to the “Openfire Administration Console” login page. You should use the username admin and the new password you setup earlier to log in. Additional settings can be fine-tuned on this page.

Need help?

Do you need help setting up this on your own service?
Please contact us and we’ll provide you the best possible quote!