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:

1
yum -y update

Install basic system config tools:

1
yum -y install system-config-firewall system-config-firewall-tui system-config-network system-config-network-tui

Install development packages:

1
yum -y install wget git gcc g++ gcc-c++ perl ncurses-devel openssl-devel unixODBC-devel libyaml-devel expat-devel zlib-devel mysql-devel

Server Init

Follow all instructions to initialize your server.

Disable Firewall

Disable firewall from system config tool:

1
system-config-firewall

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:

1
vi /etc/sysconfig/selinux

Reboot the server to actually disable SELinux:

1
reboot

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

1
sestatus

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:

1
2
mkdir -p /root/src
cd ~/src

Get the current ejabberd 16.01:

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:

Compile and Install Erlang/OTP 17.1

Compile and install Erlang/OTP 17.1:

1
2
3
cd ~/src
tar -zxf otp_src_17.1.tar.gz
cd otp_src_17.1

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

1
./configure --prefix=/usr/local --disable-hipe --enable-smp-support --enable-threads --enable-kernel-poll

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:

1
2
make
make install

Compile and Install ejabberd 16.01

Add new Linux user for ejabberd:

1
useradd -m ejabberd

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

Compile and install ejabberd 16.01:

1
2
3
cd ~/src
tar -zxf ejabberd-16.01.tgz
cd ejabberd-16.01

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

1
./configure --prefix=/usr/local --enable-tools --enable-odbc --enable-mysql --enable-zlib --enable-user=ejabberd

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

Continue to compile ejabberd 16.01:

1
make

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:

1
make install

Init Script and Verification

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

1
2
cp ~/src/ejabberd-16.01/ejabberd.init /etc/init.d
chkconfig --add ejabberd.init

Continue with rebooting the server:

1
reboot

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

1
netstat -lnptu | egrep "(5222|5269|5280)"

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:

1
ejabberdctl status

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:

1
ejabberdctl register admin localhost secretpassword

Use your own secretpassword, of course.

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

1
vi /usr/local/etc/ejabberd/ejabberd.yml

Go to the end of file and add these lines:

1
2
3
4
acl:
  admin:
    user:
      - "admin": "localhost"

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

Continue with reload config:

1
ejabberdctl reload_config

Login to Web Admin

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

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:

1
vi /usr/local/etc/ejabberd/ejabberd.yml

Go to the end of file and add these lines:

1
2
3
hosts:
  - "textng.com"
  - "ngoprek.org"

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

Continue with reload config:

1
ejabberdctl reload_config

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.

Advertisements