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:
yum -y update
Install basic system config tools:
yum -y install system-config-firewall system-config-firewall-tui system-config-network system-config-network-tui
Install development packages:
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:
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
:
vi /etc/sysconfig/selinux
Reboot the server to actually disable SELinux:
reboot
Once the server up and running again check whether the SELinux is disabled:
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:
mkdir -p /root/src cd ~/src
Get the current ejabberd 16.01:
wget -c "https://www.process-one.net/downloads/downloads-action.php?file=/ejabberd/16.01/ejabberd-16.01.tgz" -O ejabberd-16.01.tgz
Please note that the above
wget
command and allwget
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:
wget -c http://erlang.org/download/otp_src_17.1.tar.gz
Compile and Install Erlang/OTP 17.1
Compile and install Erlang/OTP 17.1:
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:
./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:
make make install
Compile and Install ejabberd 16.01
Add new Linux user for ejabberd:
useradd -m ejabberd
Please note that you cannot miss the
-m
option to create a home directory for Linux userejabberd
.
Compile and install ejabberd 16.01:
cd ~/src tar -zxf ejabberd-16.01.tgz cd ejabberd-16.01
Enable some options on the source code. Below options are considered mandatory:
./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:
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:
make install
Init Script and Verification
Place the init script and configure to start ejabberd on boot:
cp ~/src/ejabberd-16.01/ejabberd.init /etc/init.d chkconfig --add ejabberd.init
Continue with rebooting the server:
reboot
Once the server started inspect whether ejabberd has also been started:
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
:
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
:
ejabberdctl register admin localhost secretpassword
Use your own
secretpassword
, of course.
Add acl
option to enable user admin
as an Administrator account:
vi /usr/local/etc/ejabberd/ejabberd.yml
Go to the end of file and add these lines:
acl: admin: user: - "admin": "localhost"
Please note that the indention and a newline at the end are important.
Continue with reload config:
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:
http://YOUR_EJABBERD_IP_ADDRESS:5280/admin
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:
vi /usr/local/etc/ejabberd/ejabberd.yml
Go to the end of file and add these lines:
hosts: - "textng.com" - "ngoprek.org"
Please note that the indention and a newline at the end are important.
Continue with reload config:
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.
Author
This howto is written by Anton Raharja.
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
LikeLike
Looks like its 16.08 issue: http://stackoverflow.com/questions/38810951/ejabberd-user-registration-command-fails-with-error-access-rules-unauthorized
LikeLike