Install Ejabberd XMPP Server in Ubuntu 16.04

In this tutorial we are using the 64 bit deb package

Step 1: Download ejabberd

Download the deb package from https://www.process-one.net/en/ejabberd/downloads/

OR alternatively, use wget to download

wget https://www.process-one.net/downloads/downloads-action.php?file=/ejabberd/17.01/ejabberd_17.01-0_amd64.deb

Now rename the package as follows:

mv downloads-action.php?file=%2Fejabberd%2F17.01%2Fejabberd_17.01-0_amd64.deb ejabberd_17.01-0_amd64.deb

Step 2: Backup ejabberd

If you are doing a fresh install, you can jump to Step 3. If you are upgrading ejabberd, take a backup of your database using the following command:

/opt/ejabberd-xx.xx/bin/ejabberdctl backup ejabberd.backup

where xx.xx is your current ejabberd version.

  • Make a copy of the backup file and the conf folder. They will be located in /opt/ejabberd-xx.xx/database/ and /opt/ejabberd-xx.xx/conf respectively.
  • Stop ejabberd node

When upgrading, also check the upgrade process from https://docs.ejabberd.im/admin/upgrade/
Note: Make sure you have the necessary backups before installing the new version.

Step 3: Install ejabberd

Install ejabberd using the following command:

dpkg -i ejabberd_17.01-0_amd64.deb

Ejabberd will be installed in the /opt folder, so change your directory to this folder.

cd /opt/ejabberd-17.01

To check if installation was successful, you should have the following folders
bin, conf, database, doc, lib and logs.

Step 4: Installing SSL Certificates

If you are using a server for production, you will need to install SSL certificates.

  • Generating a Certificate Signing Request with key. This will generate two files, the csr file and the server key. Using openssl command, you can generate the two files. This will prompt you to enter information that will be incorporated into your certificate request.
    openssl req -nodes -newkey rsa:2048 -keyout server.key -out server.csr
  • Submit your CSR file to a any CA. You use any CA for this.
  • After you receive the certificates from your CA, you need to create a pem file for ejabberd. You will have to follow concatenate according to the following order:
    1. Your domain certificate
    2. The ca certificate
    3. Your private key file

    We do this using cat command as follows, in the order mentioned above:

    cat yourdomain.crt > server.pem
    cat ca_intermediate.crt >> server.pem
    cat server.key >> server.pem
    
  • Copy the server.pem file to ejabberd conf folder

Step 5: Edit the configuration file

Configure your server using a text editor. Some of the configurations are pre-configured, however you will need to make some changes which are relevant to your requirements.

Lets configure our server:

vi /opt/ejabberd-17.01/conf/ejabberd.yml

a) Configure hosts (domain names served by ejabberd not to be confused with the ejabberd node name)
hosts:

...
  - "yourhostname"
...

b) Configure your admin user, For e.g, In the ACL section, you configure your admin user

...
admin:
  user:
    - "admin@yourhostname"
...

For a complete list of configurations, check the documentation at https://docs.ejabberd.im/admin/configuration/

Step 6: Start the server

Start ejabberd using the following command:

/opt/ejabberd-17.01/bin/ejabberdctl start

You can check the status of ejabberd using the following command:

/opt/ejabberd-17.01/bin/ejabberdctl/ejabberdctl status

Step 7: Add users

Now that you have configured your server, you will need to add some users to the server.
For e.g, we will create the admin user, using the following command:

/opt/ejabberd-17.01/bin/ejabberdctl register admin yourhostname adminpassword

replacing yourhostname and adminpassword with yours

Step 8: Open web console

Open web admin console in browser
http://yourip:5280/admin/
or
https://yourip:5281/admin/

Note: For https you will also need to configure the listener in the configuration file.

Enter your credentials using username admin@yourhostname and the password you entered while creating the admin user

If everything went fine, you should see the web console. If your server does not start you can check the logs in the log folder within the ejabberd installation folder.

You can use the following command to check if you have any errors while starting the server.

ejabberdctl debug

P.S:
If you opt for a different database other than mnesia
Follow the steps in https://docs.ejabberd.im/admin/guide/databases/mysql/

Advertisements