How to install Ejabberd 18.01 XMPP Server with Mysql on Ubuntu 16.04 and maybe debian
What is Ejabberd — The name stands for Erlang Jabber Daemon .
Ejabberd is an XMPP application server, written mainly in the Erlang programming language. It can run under several Unix-like operating systems such as Mac OS X, GNU/Linux, FreeBSD, NetBSD, OpenBSD and OpenSolaris.
Why use Ejabberd:
XMPP (Extensible Messaging and Presence Protocol) is a protocol based on Extensible Markup Language (XML) and intended for instant messaging (IM) and online presence detection
Ports which Need to be Open
5280,4560,5299
First of all , SSH into your machine and install the required dependencies
apt-get update
apt-get install make gcc libexpat1-dev libyaml-dev automake libssl-dev erlang build-essential libncurses5-dev openssl zlib1g-dev libgd-dev libwebp-dev fop xsltproc unixodbc-dev -y
Download Ejabberd 18.01
cd /opt
wget -O ejab.tgz https://www.process-one.net/downloads/downloads-action.php?file=/ejabberd/18.01/ejabberd-18.01.tgz
tar -xvzf ejab.tgz
cd ejabberd-18.01/
Configure ejabberd
./configure --enable-mysql
make
make install
Check by running ejabberdctl live
Prepare the database for Ejabberd
login to the database server and create a new user with all access to database:
GRANT ALL ON ejabberd.* TO 'ejabberd'@'%' IDENTIFIED BY 'password';
CREATE DATABASE ejabberd;
flush privileges;
Download the schema
wget https://raw.githubusercontent.com/processone/ejabberd/master/sql/mysql.sql
Install the schema in DB
mysql -h localhost/IP_Address -D ejabberd -u ejabberd -p < mysql.sql
Edit the config file /usr/local/etc/ejabberd/ejabberd.yml to make necessary changes:
Change the authentication method:
auth_method: sql
Use mysql for all the modules:
default_db: sql
and Specify the details of database
sql_type: mysql
sql_server: "IP address or RDS endpoint or localhost"
sql_database: "ejabberd"
sql_username: "ejabberd"
sql_password: "password"
## If you want to specify the port:
sql_port: 3306
Register a user
ejabberdctl register admin localhost password_here
Edit the config file /usr/local/etc/ejabberd/ejabberd.yml to make the user admin
###. ====================
###' ACCESS CONTROL LISTS
acl:
##
## The 'admin' ACL grants administrative privileges to XMPP accounts.
## You can put here as many accounts as you want.
##
admin:
user:
- "admin@localhost"
## - "ermine@example.org"
Finally, Start Ejabberd
ejabberdctl start
Compiling from source erlang:
How to Install and Setup Erlang on Ubuntu?
Erlang is a general-purpose functional programming language and open source used for real-time scalability and high availability at the time of system requirement. It has inbuilt support for concurrency, distribution and fault tolerance. Erlang widely used in many industries like instant messaging, automobile, eCommerce, banking etc.
The following steps are the installation procedure of Erlang in the Ubuntu server:
STEP 1: Download the Erlang in the Ubuntu Server
In Linux server, download the Erlang source file using the below link. Here Erlang version of 18.0 is used and this extends the updates regularly.
The wget command is used to download the Erlang source files.
$ wget http://erlang.org/download/otp_src_18.0.tar.gz
STEP 2: Extract the Erlang tar File
Extract the downloaded tar file using the command.
$ tar -xvzf otp_src_18.0.tar.gz
STEP 3: Adding Dependencies in the Command
Provide the required dependencies in the single library function to perform a specific task. Below listed are the dependencies that will do a certain task.
$ sudo apt-get install gcc make build-essential libncurses5-dev openssl libssl-dev fop xsltproc unixodbc-dev libwxbase3.0 libwxgtk3.0-dev libqt4-opengl-dev autoconf
STEP 4: Start Compilation and Install the Erlang
To compile the source code use “make” command that starts to execute the file and finally install the Erlang using “make install” on the Linux server. The configure command will help you to verify the dependencies.
$ sudo ./configure
$ sudo make
$ sudo make install
The mentioned steps are the simple way to install the Erlang program on the Ubuntu Server.
Read : How to Build Chat App like WhatsApp?
How to Install and Start Ejabberd XMPP Server on Ubuntu?
Ejabberd is an XMPP (Extensible Messaging Presence Protocol) programming server written using Erlang programming language. One of the most popular open sources and free software. Ejabberd runs on multiple operating systems like Linux, Mac, Unix, Windows etc. XMPP is the backbone that allows to send real-time messages, online presence indicators, XML routing features and more.
Upcoming section will explain the installation of Ejabberd XMPP server on Ubuntu 14.04/16.04 in detail.
STEP 1: Download the Ejabberd in the Ubuntu Server
In Linux server, download the Ejabberd source file using the below link. Here Ejabberd version of 16.08 is used and this extends the updates regularly.
The wget command is used to download the Ejabberd source files.
$ wget https://www.process-one.net/downloads/ejabberd/16.08/ejabberd-16.08.tgz
STEP 2: Extract the Ejabberd tar File
Extract the downloaded tar file using the command.
$ tar -xvzf ejabberd-16.08.tgz
STEP 3: Adding Dependencies in the Command
Provide the required dependencies in the single library function to perform a specific task. Below listed are the dependencies that will do a certain task.
$ sudo apt-get install rebar libyaml-dev libexpat1-dev
STEP 4: Fix and Verify the Issue
autogen.sh used for compilation, verification of the functionality and overcome the initial issues.
$ ./autogen.sh
STEP 5: Start Execution and Install the Ejabberd
To compile the source code use “make” command that starts to execute the file and finally install the Erlang using “make install” on the Linux server. The configure command will help you to verify the dependencies.
$ sudo ./configure
$ sudo make
$ sudo make install
STEP 6: Open the Ejabberd Configuration File
Using the command, open the Ejabberd file to set the database.
$ sudo nano /etc/ejabberd/ejabberd.yml
If you need MySQL database follow the mention command to enable the IP, Database name, User name, Password.
1) Comment the following lines in ejabberd.yml file
#auth_method: internal
2) Uncomment the following lines in ejabberd.yml file
auth_method: sql
sql_type: mysql
sql_server: “52.13.12.123″ (Mysql Database IP)
sql_database: “databasename” (Database name)
sql_username: “root” (Database user name)
sql_password: “password” (Database password)
Finally, save the file /etc/ejabberd/ejabberd.yml
STEP 7: Run the Ejabberd
Once the changes are done, run the Ejabberd which in turn helps to refresh the database.
$ sudo ejabberdctl start
STEP 8: Check the Status using Local Host
To verify and to check the status of the ejabberd installation use the below command.
$ sudo ejabberdctl status
The node Ejabberd at Localhost starts with the status command and shows the ejabberd 16.08 is running
Using a localhost IP http://localhost:5222 the browser displays the XML.
The above steps are easy ways to install and start running the Ejabberd program in XMPP on the Ubuntu.
After the installation of Ejabberd, use the open source XMPP client libraries for Web – strophe JS, Android – Smack JAVA, and iOS – Robbiehanson for developing the chat application.
In order to build and implement a messaging app, various features are required such as One to One chat, group chat, audio/video calling and much more. Try Contus Fly to avoid complexity in building a chat app on your own.
About The Author
Sujan Kumar
Sujan Kumar is a Senior Application Developer at Contus. His passionate love towards the coding makes him spend hours in debugging and wish to develop the astonishing app that immensely helps every individual.
Related Posts
banner How to setup Amazon S3 with Cloud front as a CDN?
Amazon Web Service How to change the Amazon instance root volume capacity?
AWS change location How to change the instance from one region to another region?
Leave a Reply
Nihitan
1 year 1 month ago
I want to build an ios chat app using ejabberd as backend.
Reply
Cholan
1 year 1 month ago
Is it important to use turnkey Ejabberd on Amazon EC2 or can we install it ourselves on AMI running Linux?
Reply
chegekhan
1 year 1 month ago
Useful Information, your blog is sharing unique information.
Thanks for sharing!!!