Monday, May 5, 2014

How to install Openfire 3.9.2 on Ubuntu Server 12.04 LTS

Dear readers,

I have been unable to find a complete guide on how to install Openfire on Ubuntu, so I have decided to write one for my own reference and for others who are interested on the how-to. I hope this is beneficial to anyone who needs to get this done. The aim is to make it as brief as possible.

1. On the Ubuntu Server 12.04

There are sometimes problem with the DNS, so we've got to edit the hostname in the /etc/hosts as well.

$sudo apt-get update
$sudo apt-get upgrade
$sudo vim /etc/hosts

Then add the following entry to the hosts: YourHostNameHere

Be sure to open the following ports for Openfire to work:
  • 3478 - STUN Service (NAT connectivity)
  • 3479 - STUN Service (NAT connectivity)
  • 5222 - Client to Server (standard and encrypted)
  • 5223 - Client to Server (legacy SSL support)
  • 5229 - Flash Cross Domain (Flash client support)
  • 7070 - HTTP Binding (unsecured HTTP connecitons)
  • 7443 - HTTP Binding (secured HTTP connections)
  • 7777 - File Transfer Proxy (XMPP file transfers)
  • 9090 - Admin Console (unsecured)
  • 9091 - Admin Console (secured)

2. Install Java 8

(We'd have to do this manually since Ubuntu ditched Java some few years ago).
(Contents are from this page here: Link Thanks to he who posted this).
$sudo add-apt-repository ppa:webupd8team/java
$sudo apt-get update
$sudo apt-get install oracle-java8-installer
Once installed, running "java -version" in a terminal should output something like this:
$ java -version
java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b132)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode)
Or, "javac -version":
$ javac -version
javac 1.8.0
And so on.

To automatically set up the Java 8 environment variables, you can install the following package:
$sudo apt-get install oracle-java8-set-default

3. Download and Install Openfire 3.9.2

User wget command to download Openfire to a directory of your choice. This case, I make a new folder on the home directory called 'installs', and navigated to it.

And I changed the name of the downloaded file to a more sensible one.

Untar it, and move the result openfire directory to /opt/

$cd ~
$mkdir installs
$cd installs


$mv downloadServlet\?filename\=openfire%2Fopenfire_3_9_2.tar.gz openfire_3_9_2.tar.gz

$sudo mv openfire /opt/

(You might want to change the version number if you are from the future...I mean if there's a newer version during the time of your installation.)

4. Configure Openfire

(From: This guide, Thank you)

Edit the configuration file /opt/openfire/conf/openfire.xml, inserting your internal IP address in the <interface> section, and removing the "<!-- -->" comment markers that surround the <network> section. While not required, this action is helpful if your Linode has multiple IP addresses, and you wish to limit access to a single address.

File excerpt:

  1. <interface></interface>
- Add a symbolic link for the daemon script to /etc/init.d so that you can start the daemon with a call to service. 
- Make Openfire an autostart service if the server is rebooted.
- And then start Openfire.

  1. $sudo ln -s /opt/openfire/bin/openfire /etc/init.d/
    $sudo update-rc.d openfire defaults
    $sudo service openfire start
Now you can use your browser to navigate to your Openfire configuration page:


Please refer to this guide, on how to configure your settings on the configuration page. See next section [5.] for your choice of a database.

5. MySQL or Openfire Embedded database (Ignore this one if you are not using a dedicated database)

You will be given a choice during your settings on the configuration page. If you don't feel the need to use a dedicated database, please just choose the embedded database Openfire offers. On the other hand, it's a best practice to use a dedicated database server for your Openfire, which can be installed on your Ubuntu server. In this case, I choose MySQL which comes handily with LAMP. Please follow the instruction below. (I'd figure if you don't need LAMP, you could install just MySQL only.)

(From this guide, Thank you.)

Install LAMP Stack (Linux,Apache, Mysql, PHP) with command below:
$sudo apt-get install lamp-server^
Install PHP5 (Some applications require other PHP5 mods) with command:
$sudo apt-get install php5 php5-gd php5-mysql php5-curl php5-cli php5-cgi php5-dev
Install phpmyadmin (Choose apache2 by hitting the space bar, then tab to OK and hit Enter).
$sudo apt-get install phpmyadmin
Then create a database for your Openfire with your MySQL credentials:

$mysqladmin -u username -p create [databaseName]
After this, you should be able to use your database in the Openfire Configuration page.
Note: For best practice, it's vital for security purposes to create an openfire user account to use the database along with its credentials. But this is beyond the scope of this guide. If you're a first-timer but want to try this out fast, just use the root account and password.

7. Summary

Well that's it. I hope you enjoy the tutorial and hopefully it is as painless as I had wished it to be.
Have a great one guys!