ejabberd chat server on CentOS 7
Hi people, every now and then, I feel to have a need of a private chat server which me and my friends can use and are sure that no matter what we talk about, the logs should not go out to third party servers. Well, it’s pretty easy actually, you can create your own chat server using good old ejabberd software which has been around for a pretty decent time now and is well tested within organizations.
In this tutorial, I will walk you through the steps you need to configure a chat server on CentOS 7 machine. Fasten your seat belts, we are going to take a small ride (of course virtual one) in the technology wagon and explore ejabberd.
Installing ejabberd on CentOS 7
As there is no RPM package as of now for EL7 (not even in epel), we need to go ahead and install it from source, so head over to the website and get the installer package, which as of this writing is 16 MB. To go to the download page, click here. Download the installer package which suits your CentOS installation (32-bit or 64-bit), in my case, I downloaded 64-bit version. This will download the installer package named as: “ejabberd-14.07-linux-x86_64-installer.run”. Once download completes, make sure this is executable by running the following command:
# chmod +x ejabberd-14.07-linux-x86_64-installer.run
Run the installation and follow the on screen instructions:
1. Language selection, press ‘Enter’ for English.
2. Read the license agreement, press ‘Enter’ a couple of times and when finished, it will ask you to accept it by pressing ‘y’ for yes or ‘n’ for no. Press ‘y’ and hit enter.
3. Specify the installation directory, by default it will place the files at: ‘/opt/ejabberd-13.07’ which is fine for most of the cases, hit ‘Enter’ to chose this default installation path or specify your own.
4. Next, specify the domain name, by default ‘localhost’ will be set but I would recommend you to set to FQDN which must be resolvable using hosts file or the DNS. This is because when you will add users, you will need to use this domain (resolvable) as well, in my case, i choose ‘techlinux.net’, so when I create a user, it will be as: firstname.lastname@example.org which will be my XMPP ID on this server.
5. Administrator username: ‘admin’ is by default and I will let it be, because I can add other users after the initial configuration. This ‘admin’ user will only be used to manage ‘stuff’ from a GUI.
6. Administrator password: Make sure to set it to something very strong and safe it in a secure location. If someone get’s their hands on this password, then they can control your XMPP (chat) server from a web browser as we will see in few steps.
7. Is this node a part of a cluster? I don’t think so, hit ‘Enter’ and it will choose ‘No’ by default.
8. Installation is ready to be performed, hit ‘y’ and hit ‘Enter’ to install the setup.
9. View ‘Read Me’ file, press ‘n’ and hit ‘Enter’.
What you should see?:
You can view the directory structure by “cd’ing” into: /opt/ejabberd-14.07/, we are mostly interested into two of them, that is: bin/ and conf/ directories.
bin/ – it contains all the binaries to start/stop the ejabberd services.
conf/ – it has all the configuration files which you can play with on your own.
We will go ahead and start the service now:
# cd /opt/ejabberd-14.07/bin/ # ./ejabberdctl start //this will start the service and web interface on port number 5280
To manage the users and hosts, and apparently anything, you can log into the web interface as:
where X.X.X.X is the IP address of the server or you may use the domain name if it is resolvable.
What you should see?:
NOTE: When you first access the web interface, it will ask for a username and a password, use the full username including the domain as: admin@FQDN (in my case, I used: email@example.com) with the associated password.
<h2>How to connect to your server using Pidgin </h2>
<h3> Some notes about pidgin </h3>
Pidgin (previously known as GAIM), as most of the people who uses Linux OS for their daily use know, is the favorite chat client that can add multiple accounts (AIM, Facebook [XMPP], Gadu-Gadu, Google Talk, ICQ, IRC, MSN, Yahoo etc.) at a single place. It also let you add any chat service that works on XMPP. That is where our chat server comes into action, as it is also based on XMPP, we can certainly configure it using Pidgin. Steps are as follows:
1. Download and install Pidgin for windows from: https://www.pidgin.im/download/windows/.
People using Linux as their desktops can install it from their OS repository, for example, in Arch Linux, I would simply do the following which will install Pidgin:
# pacman -Sy pidgin
2. Run it and click on ‘Accounts > Manage Accounts > Add‘.
3. Details should be as follows:
Username: aman.hanjrah (this would be the user using which you want to connect to your chat server)
Domain: techlinux.net (this would be the domain name for which you have configured your chat server in one of the steps mentioned above in the section: Installing ejabberd on CentOS 7)
Resource: You can leave this empty.
Password: Associated password.
Remember password: checked.
Local alias: If you want to give a local alias to the users that would appear in your friend list.
4. Click ‘Add’.
5. Accept the certificate and you should be logged in successfully. If not, you will see the error message in the main Pidgin window to the downward as shown in the screen shot below.
6. You have now configured your chat server correctly and it should be all set to accept chats. Add another account and ‘add’ that user in your friend list for testing purposes, then try to send messages over.
For advanced options, you can download (or view online) the “ejabberd” documentation which has some pretty neat functionality you may opt for your chat server. You can find it at:
I hope this has been informative for you, in case you have any queries, feel free to leave a comment below.