In the recent article, we talked about how you can install and configure Ejabberd XMPP server. XMPP( Extensible Messaging and Presence Protocol) is a widely adopted open protocol for instant messaging. Openfire is a free to use and powerful instant messaging (IM) server that uses XMPP/Jabber protocol. This article will be focused on setting up Openfire XMPP Chat Server on Ubuntu 20.04 Linux machine

Here are some of the cool features provided by Openfire:

  • LDAP integration support
  • MySQL, Oracle, PostgreSQL and embedded database support for user details and massages storage.
  • Support both TLS and SSL for security
  • A lot of plugins to extend its functionality
  • Web GUI configuration manager
  • Spark IM client integration
  • Clustering to avoid a single point of failure
  • Integrating with other external IM servers

Below are the standard steps you’ll follow to install and configure Openfire XMPP Chat Server on Ubuntu 20.04.

Step 1: Update System

Make sure you’re working on an updated version of Ubuntu Linux.

sudo apt update

Upgrading installed packages is optional.

sudo apt upgrade

If you perform OS upgrade, a reboot is necessary:

sudo systemctl reboot

Step 2: Install Openfire XMPP Server on Ubuntu 20.04

Download Openfire latest package. The version we’ll install in this article is 4.5.2.

wget https://www.igniterealtime.org/downloadServlet?filename=openfire/openfire_4.5.2_all.deb -O openfire.deb

Once the Openfire debian package has been downloaded, install it with the apt command:

sudo apt install ./openfire.deb

Accept installation prompt by pressing the y key in your keyboard.

The following additional packages will be installed:
  ca-certificates-java default-jre-headless fontconfig-config fonts-dejavu-core java-common libavahi-client3 libavahi-common-data libavahi-common3
  libcups2 libfontconfig1 libjpeg-turbo8 libjpeg8 liblcms2-2 libnspr4 libnss3 libpcsclite1 libx11-6 libx11-data libxau6 libxcb1 libxdmcp6 libxext6
  libxi6 libxrender1 libxtst6 openjdk-11-jre-headless x11-common
Suggested packages:
  default-jre cups-common liblcms2-utils pcscd libnss-mdns fonts-dejavu-extra fonts-ipafont-gothic fonts-ipafont-mincho fonts-wqy-microhei
  | fonts-wqy-zenhei fonts-indic
The following NEW packages will be installed:
  ca-certificates-java default-jre-headless fontconfig-config fonts-dejavu-core java-common libavahi-client3 libavahi-common-data libavahi-common3
  libcups2 libfontconfig1 libjpeg-turbo8 libjpeg8 liblcms2-2 libnspr4 libnss3 libpcsclite1 libx11-6 libx11-data libxau6 libxcb1 libxdmcp6 libxext6
  libxi6 libxrender1 libxtst6 openfire openjdk-11-jre-headless x11-common
0 upgraded, 28 newly installed, 0 to remove and 0 not upgraded.
Need to get 41.3 MB/80.5 MB of archives.
After this operation, 230 MB of additional disk space will be used.
Do you want to continue? [Y/n] y

Start and enable openfire service to start at system boot.

sudo systemctl enable --now openfire

Check service status if it is running.

$ systemctl status openfire
● openfire.service - LSB: Start/stop openfire jabber server
     Loaded: loaded (/etc/init.d/openfire; generated)
     Active: active (running) since Sat 2020-05-23 17:10:43 CEST; 2min 41s ago
       Docs: man:systemd-sysv-generator(8)
      Tasks: 32 (limit: 4567)
     Memory: 199.9M
     CGroup: /system.slice/openfire.service
             └─1800 /bin/java -server -DopenfireHome=/usr/share/openfire -Dlog4j.configurationFile=/usr/share/openfire/lib/log4j2.xml -Dopenfire.lib.di>

May 23 17:10:43 ubuntu systemd[1]: Starting LSB: Start/stop openfire jabber server...
May 23 17:10:43 ubuntu openfire[1784]: best java alternative in:
May 23 17:10:43 ubuntu openfire[1784]: Starting openfire: openfire.
May 23 17:10:43 ubuntu systemd[1]: Started LSB: Start/stop openfire jabber server.

Step 3: Configure Database support for Openfire XMPP Server

We’ll use MariaDB database to store message data. Install MariaDB database server with the commands below.

sudo apt update
sudo apt -y install mariadb-server

Create database for openfire:

$ sudo mysql -u root
CREATE DATABASE openfire;
GRANT ALL PRIVILEGES ON openfire.* TO [email protected] IDENTIFIED BY '[email protected]!';
FLUSH PRIVILEGES;
QUIT

Import Openfire database schema:

$ mysql -u openfire -p'[email protected]!'
USE openfire;
source /usr/share/openfire/resources/database/openfire_mysql.sql;

Confirm by listing the tables in the database.

MariaDB [openfire]> SHOW tables;
 ---------------------- 
| Tables_in_openfire   |
 ---------------------- 
| ofExtComponentConf   |
| ofGroup              |
| ofGroupProp          |
| ofGroupUser          |
| ofID                 |
| ofMucAffiliation     |
| ofMucConversationLog |
| ofMucMember          |
| ofMucRoom            |
| ofMucRoomProp        |
| ofMucService         |
| ofMucServiceProp     |
| ofOffline            |
| ofPresence           |
| ofPrivacyList        |
| ofProperty           |
| ofPubsubAffiliation  |
| ofPubsubDefaultConf  |
| ofPubsubItem         |
| ofPubsubNode         |
| ofPubsubNodeGroups   |
| ofPubsubNodeJIDs     |
| ofPubsubSubscription |
| ofRemoteServerConf   |
| ofRoster             |
| ofRosterGroups       |
| ofSASLAuthorized     |
| ofSecurityAuditLog   |
| ofUser               |
| ofUserFlag           |
| ofUserProp           |
| ofVCard              |
| ofVersion            |
 ---------------------- 
33 rows in set (0.001 sec)

Step 4: Configure Firewall and Access Openfire UI

If you have an active firewall service, allow ports for Openfire.

for i in 9090 9091 5222 7777; do sudo ufw allow $i; done

Access Openfire Web interface on the Server using the IP address or server hostname and port 9090. On the first prompt choose installation language:

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/05/echo/install-openfire-ubuntu-18.04-ubuntu-16.04-01.png" data-ez ezimgfmt="rs rscb8 src ng ngcb8 srcset" src="data:image/svg xml,”>

Select your default language then click Continue.  On Server setup window, set your domain and click Continue button.

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/05/echo/install-openfire-ubuntu-18.04-ubuntu-16.04-02.png" data-ez ezimgfmt="rs rscb8 src ng ngcb8 srcset" src="data:image/svg xml,”>

For Database Settings, choose Standard Database Connection.

You can as well use Embedded Database if you don’t want to use MySQL database.

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/05/echo/install-openfire-ubuntu-linux-01-1024×243.png" data-ez ezimgfmt="rs rscb8 src ng ngcb8 srcset" src="data:image/svg xml,”>

These are the a parameters I’ll use:

  • Database Driver Presets:MySQL
  • JDBC Driver Class: com.mysql.jdbc.Driver
  • Database URL:jdbc:mysql://127.0.0.1/openfire?useUnicode=true characterEncoding=UTF-8&characterSetResults=UTF-8
  • Username: openfire
  • Password: [email protected]!

This is my screenshot.

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/05/echo/install-openfire-ubuntu-18.04-ubuntu-16.04-03.png" data-ez ezimgfmt="rs rscb8 src ng ngcb8 srcset" src="data:image/svg xml,”>

Click Continue and use Default option on Profile Settings; You can later add external authentication mechanisms like LDAP

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/05/echo/install-openfire-ubuntu-18.04-ubuntu-16.04-04.png" data-ez ezimgfmt="rs rscb8 src ng ngcb8 srcset" src="data:image/svg xml,”>

Set admin user email address and password:

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/05/echo/install-openfire-ubuntu-18.04-ubuntu-16.04-05.png" data-ez ezimgfmt="rs rscb8 src ng ngcb8 srcset" src="data:image/svg xml,”>

Login to Openfire console in the next page.

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/05/echo/install-openfire-ubuntu-18.04-ubuntu-16.04-06-login.png" data-ez ezimgfmt="rs rscb8 src ng ngcb8 srcset" src="data:image/svg xml,”>

Enjoy using Openfire.

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/05/echo/install-openfire-ubuntu-linux-02-1024×552.png" data-ez ezimgfmt="rs rscb8 src ng ngcb8 srcset" src="data:image/svg xml,”>