Wednesday, 29 May 2019

Install Openfire XMPP Server on CentOS 7

Install Openfire XMPP Server on CentOS 7

Openfire is a cross-platform real-time collaboration server developed in Java and based on the XMPP / Jabber protocol. Openfire is formerly known as Wildfire and Jive Messenger. It is developed by Jive Software and maintained by Ignite Realtime community. Openfire is free and open-source and distributed under Apache License 2.0.

In this article, we will install Openfire XMPP Server on CentOS 7 and then we will use Spark client to connect with our Openfire XMPP server.

 

This Article Provides:

     

    System Specification:

    We have provisioned a CentOS 7 virtual machine with following specification.

    • Hostname - openfire-01.example.com
    • IP Address - 192.168.116.170 /24
    • Operating System - CentOS 7.6

    We will configure the above CentOS 7 machine as Openfire server and used our Host machine (MS Windows) to install and test our Openfire server using Spark client.

     

    Installing MariaDB server on CentOS 7:

    We will configure Openfire to use an external database for optimum performance. For this purpose, we are installing MariaDB database server using yum command.

    [root@openfire-01 ~]# yum install -y mariadb-server ... Installed: mariadb-server.x86_64 1:5.5.60-1.el7_5 Dependency Installed: mariadb.x86_64 1:5.5.60-1.el7_5 perl.x86_64 4:5.16.3-294.el7_6 perl-Carp.noarch 0:1.26-244.el7 perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7 perl-DBD-MySQL.x86_64 0:4.023-6.el7 perl-DBI.x86_64 0:1.627-4.el7 perl-Data-Dumper.x86_64 0:2.145-3.el7 perl-Encode.x86_64 0:2.51-7.el7 perl-Exporter.noarch 0:5.68-3.el7 perl-File-Path.noarch 0:2.09-2.el7 perl-File-Temp.noarch 0:0.23.01-3.el7 perl-Filter.x86_64 0:1.49-3.el7 perl-Getopt-Long.noarch 0:2.40-3.el7 perl-HTTP-Tiny.noarch 0:0.033-3.el7 perl-IO-Compress.noarch 0:2.061-2.el7 perl-Net-Daemon.noarch 0:0.48-5.el7 perl-PathTools.x86_64 0:3.40-5.el7 perl-PlRPC.noarch 0:0.2020-14.el7 perl-Pod-Escapes.noarch 1:1.04-294.el7_6 perl-Pod-Perldoc.noarch 0:3.20-4.el7 perl-Pod-Simple.noarch 1:3.28-4.el7 perl-Pod-Usage.noarch 0:1.63-3.el7 perl-Scalar-List-Utils.x86_64 0:1.27-248.el7 perl-Socket.x86_64 0:2.010-4.el7 perl-Storable.x86_64 0:2.45-3.el7 perl-Text-ParseWords.noarch 0:3.29-4.el7 perl-Time-HiRes.x86_64 4:1.9725-3.el7 perl-Time-Local.noarch 0:1.2300-2.el7 perl-constant.noarch 0:1.27-2.el7 perl-libs.x86_64 4:5.16.3-294.el7_6 perl-macros.x86_64 4:5.16.3-294.el7_6 perl-parent.noarch 1:0.225-244.el7 perl-podlators.noarch 0:2.5.1-3.el7 perl-threads.x86_64 0:1.87-4.el7 perl-threads-shared.x86_64 0:1.43-6.el7 Complete!

    Enable and start MariaDB service.

    [root@openfire-01 ~]# systemctl enable mariadb.service Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service. [root@openfire-01 ~]# systemctl start mariadb.service

    Configure MariaDB instance as follows.

    [root@openfire-01 ~]# mysql_secure_installation NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and you haven't set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none): OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation. Set root password? [Y/n] Y New password: Re-enter new password: Password updated successfully! Reloading privilege tables.. ... Success! By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] Y ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] Y ... Success! By default, MariaDB comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] Y - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] Y ... Success! Cleaning up... All done! If you've completed all of the above steps, your MariaDB installation should now be secure. Thanks for using MariaDB!

    MariaDB has been installed successfully. If you want to install a latest release of MariaDB then please refer to our previous article Installing MariaDB 10.3 Server on CentOS 7.

     

    Installing Openfire XMPP Server on CentOS 7:

    Connect with openfire-01.example.com using ssh as root user.

    Download latest version (currently Openfire 4.3.2) from Ignite Realtime Website.

    There are two variations of Openfire are available here i.e. with or without JRE. We recommend you to download and install the Openfire with JRE. Otherwise you have to explicitly install OpenJDK before installing Openfire without JRE.

    [root@openfire-01 ~]# cd /tmp [root@openfire-01 tmp]# wget -O openfire-4.3.2-1.x86_64.rpm https://www.igniterealtime.org/downloadServlet?filename=openfire/openfire-4.3.2-1.x86_64.rpm --2019-05-26 14:01:20-- https://www.igniterealtime.org/downloadServlet?filename=openfire/openfire-4.3.2-1.x86_64.rpm Resolving www.igniterealtime.org (www.igniterealtime.org)... 52.58.216.59 Connecting to www.igniterealtime.org (www.igniterealtime.org)|52.58.216.59|:443... connected. HTTP request sent, awaiting response... 302 Location: http://download.igniterealtime.org/openfire/openfire-4.3.2-1.x86_64.rpm [following] --2019-05-26 14:01:21-- http://download.igniterealtime.org/openfire/openfire-4.3.2-1.x86_64.rpm Resolving download.igniterealtime.org (download.igniterealtime.org)... 52.58.216.59 Connecting to download.igniterealtime.org (download.igniterealtime.org)|52.58.216.59|:80... connected. HTTP request sent, awaiting response... 302 Found Location: https://github.com/igniterealtime/Openfire/releases/download/v4.3.2/openfire-4.3.2-1.x86_64.rpm [following] --2019-05-26 14:01:21-- https://github.com/igniterealtime/Openfire/releases/download/v4.3.2/openfire-4.3.2-1.x86_64.rpm Resolving github.com (github.com)... 192.30.253.112 Connecting to github.com (github.com)|192.30.253.112|:443... connected. HTTP request sent, awaiting response... 302 Found Location: https://github-production-release-asset-2e65be.s3.amazonaws.com/18511687/e1599f00-254c-11e9-86b4-af3416540b3e?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20190526%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190526T090122Z&X-Amz-Expires=300&X-Amz-Signature=1b28d4b39d5ec17d56a6154fa0c24b51792790574cd3eb692b981f06d3582261&X-Amz-SignedHeaders=host&actor_id=0&response-content-disposition=attachment%3B%20filename%3Dopenfire-4.3.2-1.x86_64.rpm&response-content-type=application%2Foctet-stream [following] --2019-05-26 14:01:22-- https://github-production-release-asset-2e65be.s3.amazonaws.com/18511687/e1599f00-254c-11e9-86b4-af3416540b3e?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20190526%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190526T090122Z&X-Amz-Expires=300&X-Amz-Signature=1b28d4b39d5ec17d56a6154fa0c24b51792790574cd3eb692b981f06d3582261&X-Amz-SignedHeaders=host&actor_id=0&response-content-disposition=attachment%3B%20filename%3Dopenfire-4.3.2-1.x86_64.rpm&response-content-type=application%2Foctet-stream Resolving github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)... 52.216.112.195 Connecting to github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)|52.216.112.195|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 120645764 (115M) [application/octet-stream] Saving to: âopenfire-4.3.2-1.x86_64.rpmâ 100%[======================================>] 120,645,764 573KB/s in 4m 17s 2019-05-26 14:05:41 (458 KB/s) - âopenfire-4.3.2-1.x86_64.rpmâ saved [120645764/120645764]

    Install Openfire package using rpm command.

    [root@openfire-01 tmp]# rpm -ivh openfire-4.3.2-1.x86_64.rpm Preparing... ################################# [100%] Updating / installing... 1:openfire-4.3.2-1 ################################# [100%] Restarting openfire (via systemctl): [ OK ]

    Openfire service is already enabled during package installation, therefore, there we are only required to start it once.

    [root@openfire-01 tmp]# systemctl is-enabled openfire openfire.service is not a native service, redirecting to /sbin/chkconfig. Executing /sbin/chkconfig openfire --level=5 enabled [root@openfire-01 tmp]# systemctl start openfire

    Check the status of the Openfire service.

    [root@openfire-01 tmp]# systemctl status openfire â openfire.service - SYSV: Openfire is an XMPP server, which is a server that facilitates XML based communication, such as chat. Loaded: loaded (/etc/rc.d/init.d/openfire; bad; vendor preset: disabled) Active: active (running) since Sun 2019-05-26 14:24:06 PKT; 1s ago Docs: man:systemd-sysv-generator(8) Process: 15499 ExecStart=/etc/rc.d/init.d/openfire start (code=exited, status=0/SUCCESS) Main PID: 15513 (java) CGroup: /system.slice/openfire.service ⣠15513 /opt/openfire/jre/bin/java -Dlog4j.configurationFile=/opt/... May 26 14:24:04 openfire-01.example.com systemd[1]: Starting SYSV: Openfire i... May 26 14:24:05 openfire-01.example.com su[15511]: (to daemon) root on none May 26 14:24:05 openfire-01.example.com openfire[15499]: Starting openfire: May 26 14:24:06 openfire-01.example.com systemd[1]: Started SYSV: Openfire is... Hint: Some lines were ellipsized, use -l to show in full.

    Openfire Service is successfully started.

     

    Configure Linux Firewall to Allow Openfire Service ports:

    Allow Openfire service ports in Linux firewall as follows.

    [root@openfire-01 tmp]# firewall-cmd --permanent --add-port={9090,5222}/tcp success [root@openfire-01 tmp]# firewall-cmd --reload success

     

    Create a MariaDB Database for Openfire Server:

    Create a database for Openfire in MariaDB server.

    [root@openfire-01 tmp]# mysql -u root -p123 Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 13 Server version: 5.5.60-MariaDB MariaDB Server Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> CREATE DATABASE openfire; Query OK, 1 row affected (0.00 sec) MariaDB [(none)]> GRANT ALL ON openfire.* to 'openfire'@'localhost' IDENTIFIED BY '123'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> GRANT ALL ON openfire.* to 'openfire'@'openfire-01.example.com' IDENTIFIED BY '123'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> EXIT Bye

    Connect as openfire user and create database schema in openfire database using the scripts provided within Openfire home directory.

    [root@openfire-01 tmp]# mysql -u openfire -p123 Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 15 Server version: 5.5.60-MariaDB MariaDB Server Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> USE openfire; Database changed MariaDB [openfire]> SOURCE /opt/openfire/resources/database/openfire_mysql.sql Query OK, 0 rows affected (0.04 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.01 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.01 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.01 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.01 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.01 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.01 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.01 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 1 row affected (0.00 sec) Query OK, 1 row affected (0.00 sec) Query OK, 1 row affected (0.00 sec) Query OK, 1 row affected (0.00 sec) Query OK, 1 row affected (0.00 sec) Query OK, 1 row affected (0.00 sec) Query OK, 1 row affected (0.00 sec)

    Check list of tables in openfire 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.00 sec) MariaDB [openfire]> EXIT Bye

     

    Configure Openfire server on CentOS 7:

    To start Openfire setup, browse URL http://openfire-01.example.com:9090/ in a client's browser.

    01-openfire-xmpp-choose-language

    Choose your preferred language and click on Continue.

    02-openfire-xmpp-server-settings

    Configure Server Settings as mentioned in above screenshot and click on Continue.

    03-openfire-xmpp-database-settings

    We have configured a MariaDB database for our Openfire server. Therefore, choose Standard Database Connection on Database Settings page and click on Continue.

    04-openfire-xmpp-standard-database-connection

    Define Database Connection settings according to above screenshot and click on Continue.

    05-openfire-xmpp-profile-settings

    You are at the Profile Settings page. Accept the default settings and click on Continue.

    06-openfire-xmpp-administrator-account

    Define email address and password for Administrator Account and click on Continue.

    07-openfire-xmpp-setup-complete

    Setup is completed. Click on Login to the admin console to access Openfire web UI.

    08-openfire-xmpp-login

    Login as admin user.

    09-openfire-xmpp-server-information

    After successful login, you may reach at the System Information page of Openfire admin console.

    Click on Users/Groups to create a new user for accessing Openfire services.

    10-openfire-xmpp-create-new-user

    Create a regular user as we have created in above screenshot.

    11-openfire-xmpp-user-properties

    User ahmer has been created.

    The user we have created is enough to demonstrate the client connectivity with Openfire server, therefore, we are not creating more users here. You can create as many users/groups as you like from the same page.

     

    Installing Spark Client for Windows:

    We have successfully configured our Openfire XMPP server on CentOS 7. Now, we need a client system and software to test our configurations.

    Ignite Realtime provides Spark software. It is a free and open-source XMPP client. We will install it on our Microsoft Windows based machine and then use it to connect with our Openfire XMPP server.

    Download Spark client from Ignite Realtime website and install it on the MS Windows. We are not going to show the installation process of Spark client, because it is pretty straight forward and you should go on with the default options.

    After installation, Run Spark client.

    12-spark-xmpp-client-login

    We can login using ahmer user, but we have to perform some additional settings before login.

    Click on Advanced.

    13-spark-xmpp-client-advanced-settings

    We have to configure two settings here:

    1.  Set hostname or IP address of Openfire server
    2.  Accept all certificates to remove certificate warning at user login.

    Click on Ok.

    12-spark-xmpp-client-login

    Click on Login.

    14-spark-xmpp-client

    We have successfully login to our Openfire XMPP server on CentOS 7 using Spark client.

    Install Openfire XMPP Server on CentOS 7


    YOU MIGHT ALSO LIKE:

    1 comment: