Howto Setup ejabberd 16 on CentOS 6.7

Introduction

Do It Yourself an Instant Messaging server, an experiment with ejabberd.

This article is divided into three parts:

  • Part 1: Prepare The Server
  • Part 2: Install ejabberd
  • Part 3: Basic Configuration

The goal of this article is to compile and install ejabberd from source on CentOS, configure admin account to enable the web admin and add an example how to configure ejabberd to support multiple domains or virtual hosts.

Part 1: Prepare The Server

Linux CentOS Minimal

Linux server installation:

  • You may use VirtualBox or any other virtualization software, or a real server
  • You may also do this in a VPS such as in DigitalOcean
  • You need fast Internet connection, we will be downloading lots of stuffs
  • Install CentOS 6.7 minimal version, get the minimal version of CentOS 6.7 installer ISO here
  • Configure the network so that the server will have access to the Internet
  • You must make sure that the SSH server is installed and running, access the server using SSH, work from outside
  • You will need to login as root during installation

Please note that you can always use full version of CentOS, the same installation steps in this article will still work.

Update: This article will also work on CentOS 7.1

Update CentOS:

[code lang=”text”]
yum -y update
[/code]

Install basic system config tools:

[code lang=”text”]
yum -y install system-config-firewall system-config-firewall-tui system-config-network system-config-network-tui
[/code]

Install development packages:

[code lang=”text”]
yum -y install wget git gcc g++ gcc-c++ perl ncurses-devel openssl-devel unixODBC-devel libyaml-devel expat-devel zlib-devel mysql-devel
[/code]

Server Init

Follow all instructions to initialize your server.

Disable Firewall

Disable firewall from system config tool:

[code lang=”text”]
system-config-firewall
[/code]

Please note that you can enable the firewall again later after successful installation and several test calls.

Disable SELINUX

Edit /etc/sysconfig/selinux and change SELINUX=enforcing to SELINUX=disabled:

[code lang=”text”]
vi /etc/sysconfig/selinux
[/code]

Reboot the server to actually disable SELinux:

[code lang=”text”]
reboot
[/code]

Once the server up and running again check whether the SELinux is disabled:

[code lang=”text”]
sestatus
[/code]

Please note that the SELinux status must be disabled.

Part 2: Install ejabberd

Download Source Codes

Prepare sources directory in /root/src, all required software source codes will be put in that directory:

[code lang=”text”]
mkdir -p /root/src
cd ~/src
[/code]

Get the current ejabberd 16.01:

[code lang=”text”]
wget -c "https://www.process-one.net/downloads/downloads-action.php?file=/ejabberd/16.01/ejabberd-16.01.tgz" -O ejabberd-16.01.tgz
[/code]

Please note that the above wget command and all wget commands below are single line only. You must make sure that the correct package will be downloaded to /root/src.

Get the required Erlang/OTP 17.1:

[code lang=”text”]
wget -c http://erlang.org/download/otp_src_17.1.tar.gz
[/code]

Compile and Install Erlang/OTP 17.1

Compile and install Erlang/OTP 17.1:

[code lang=”text”]
cd ~/src
tar -zxf otp_src_17.1.tar.gz
cd otp_src_17.1
[/code]

Enable and disable some options on the source code. Below options are considered mandatory:

[code lang=”text”]
./configure –prefix=/usr/local –disable-hipe –enable-smp-support –enable-threads –enable-kernel-poll
[/code]

Please note that the ./configure options above are important. You can find more options by running ./configure --help.

Continue to compile and install Erlang/OTP 17.1:

[code lang=”text”]
make
make install
[/code]

Compile and Install ejabberd 16.01

Add new Linux user for ejabberd:

[code lang=”text”]
useradd -m ejabberd
[/code]

Please note that you cannot miss the -m option to create a home directory for Linux user ejabberd.

Compile and install ejabberd 16.01:

[code lang=”text”]
cd ~/src
tar -zxf ejabberd-16.01.tgz
cd ejabberd-16.01
[/code]

Enable some options on the source code. Below options are considered mandatory:

[code lang=”text”]
./configure –prefix=/usr/local –enable-tools –enable-odbc –enable-mysql –enable-zlib –enable-user=ejabberd
[/code]

Please note that the ./configure options above are important. You can find more options by running ./configure --help.

Continue to compile ejabberd 16.01:

[code lang=”text”]
make
[/code]

Please note that the make command above will also download lots of stuffs from Github, therefore you need to make sure that the Internet is ready, and fast.

Continue to install ejabberd 16.01:

[code lang=”text”]
make install
[/code]

Init Script and Verification

Place the init script and configure to start ejabberd on boot:

[code lang=”text”]
cp ~/src/ejabberd-16.01/ejabberd.init /etc/init.d
chkconfig –add ejabberd.init
[/code]

Continue with rebooting the server:

[code lang=”text”]
reboot
[/code]

Once the server started inspect whether ejabberd has also been started:

[code lang=”text”]
netstat -lnptu | egrep "(5222|5269|5280)"
[/code]

Please note that you need to visually see both port 5222 , 5269 and 5280 are occupied by beam.

Also make sure that you have access to running server via ejabberdctl:

[code lang=”text”]
ejabberdctl status
[/code]

Please note that you should see the result of the command above like this: ejabberd 16.01 is running in that node

ejabberd Installation is finished, continue with basic configuration to get you started using it.

Part 3: Basic Configuration

Setup Administrator Account

Register the admin user to the default host localhost:

[code lang=”text”]
ejabberdctl register admin localhost secretpassword
[/code]

Use your own secretpassword, of course.

Add acl option to enable user admin as an Administrator account:

[code lang=”text”]
vi /usr/local/etc/ejabberd/ejabberd.yml
[/code]

Go to the end of file and add these lines:

[code lang=”css”]
acl:
admin:
user:
– "admin": "localhost"
[/code]

Please note that the indention and a newline at the end are important.

Continue with reload config:

[code lang=”text”]
ejabberdctl reload_config
[/code]

Login to Web Admin

Once you have added and setup an Administrator account you can login to the web admin by visiting this address:

[code lang=”text”]
http://YOUR_EJABBERD_IP_ADDRESS:5280/admin
[/code]

For example, browse http://192.168.56.2:5280/admin if 192.168.56.2 is your ejabberd server IP address.

Use admin@localhost as the username and your secretpassword as the password.

Add Virtual Host

Suppose you want to actually setup an IM server for domain textng.com and ngoprek.org, it means your XMPP/Jabber users will have address like username@textng.com or username@ngoprek.org. You need to add both textng.com and ngoprek.org as virtual hosts in your ejabberd.

Add textng.com and ngoprek.org as virtual hosts:

[code lang=”text”]
vi /usr/local/etc/ejabberd/ejabberd.yml
[/code]

Go to the end of file and add these lines:

[code lang=”css”]
hosts:
– "textng.com"
– "ngoprek.org"
[/code]

Please note that the indention and a newline at the end are important.

Continue with reload config:

[code lang=”text”]
ejabberdctl reload_config
[/code]

Visit web admin and see if both domains are registered as virtual hosts. Once you see them registered then you can add more users under specific host as XMPP/Jabber user.

You can then ask users to use their favorite XMPP/Jabber client software such as Xabber and ChatSecure on smartphone, or Pidgin and Jitsi on desktop, using registered usernames and passwords.

Instant Messaging server installation and basic configuration is finished.

Author

This howto is written by Anton Raharja.

2 thoughts on “Howto Setup ejabberd 16 on CentOS 6.7

  1. Fortune Multi Billing

    Nice tutorial mas, but i got this error msg:

    [root@CentOS-68-64-minimal ~]# ejabberdctl register admin localhost sensor
    {error,access_rules_unauthorized}

    Is that something wrong? I am using ejabberd 16.08

Comments are closed.