Install ejabberd | XMPP Server Guide for Ubuntu & CentOS
Managing the messaging infrastructure on IOFLOOD servers, required us to explore support for XMPP extensions, and integration with LDAP and external databases. After installing and configuring ejabberd, we found that it’s distributed architecture make it a viable option for building chat applications and communication services. This article provides concise instructions on installing ejabberd on Linux, to assist our customers in creating reliable messaging solutions on their custom server configurations.
In this tutorial, we will guide you on how to install ejabberd on your Linux system. We will provide you with installation instructions for both APT-based distributions like Debian and Ubuntu, and YUM-based distributions like CentOS and AlmaLinux. We’ll also delve into more advanced topics such as compiling ejabberd from source and installing a specific version. Finally, we will guide you on how to use ejabberd and verify that the correct version is installed.
So, let’s get started and begin installing ejabberd on your Linux system!
TL;DR: How Do I Install ejabberd on Linux?
To install Debian-based systems like Ubuntu, run
sudo apt-get install ejabberd
. For RPM-based systems like CentOS, usesudo yum install ejabberd
. You can also install ejabberd on Linux by downloading the binary installer from the ejabberd official website and running it.
Here’s a basic example:
wget https://static.process-one.net/ejabberd/downloads/latest/ejabberd-latest-linux-x64.run
chmod +x ejabberd-latest-linux-x64.run
./ejabberd-latest-linux-x64.run
# Output:
# 'Installation successful'
This is a basic way to install ejabberd on Linux, but there’s much more to learn about installing and using ejabberd. Continue reading for more detailed information and advanced installation options.
Table of Contents
- Basic ejabberd Install on Linux
- Installing ejabberd from Source
- Installing Different ejabberd Versions
- Using Docker to Install ejabberd
- Basic Usage and Verification
- Troubleshooting ejabberd Installations
- Understanding XMPP Servers
- Project Usages with ejabberd
- Exploring XMPP Protocols and More
- Recap: Ejabberd Setup on Linux
Basic ejabberd Install on Linux
Before we dive into the installation process, it’s crucial to understand what ejabberd is and why you might want to use it. Ejabberd is a robust, scalable, and extensible XMPP server. It’s written in Erlang/OTP language, which is known for its superior support in building concurrent and distributed applications. If you’re looking to build a messaging application that can scale and is reliable, ejabberd is an excellent choice.
Now, let’s move on to the installation process. We’ll cover the installation using two popular package managers: APT (used in Debian-based distributions like Ubuntu) and YUM (used in RHEL-based distributions like CentOS).
Installing ejabberd Using APT
If you’re using a Debian-based distribution, you can install ejabberd using the APT package manager. Here are the steps:
- Update your package lists:
sudo apt-get update
# Output:
# 'Hit:1 http://archive.ubuntu.com/ubuntu bionic InRelease'
- Install ejabberd:
sudo apt-get install ejabberd
# Output:
# 'Reading package lists... Done'
# 'Building dependency tree'
# 'Reading state information... Done'
# 'The following additional packages will be installed:'
# ' erlang-asn1 erlang-base erlang-crypto erlang-ejabberd erlang-inets'
# ' erlang-mnesia erlang-os-mon erlang-xmerl'
# 'Suggested packages:'
# ' erlang erlang-manpages ejabberd-contrib'
# 'The following NEW packages will be installed:'
# ' erlang-asn1 erlang-base erlang-crypto erlang-ejabberd erlang-inets'
# ' erlang-mnesia erlang-os-mon erlang-xmerl'
# '0 upgraded, 8 newly installed, 0 to remove and 31 not upgraded.'
# 'Need to get 22.8 MB of archives.'
# 'After this operation, 30.6 MB of additional disk space will be used.'
# 'Do you want to continue? [Y/n] Y'
The above commands will update your package lists and install ejabberd along with its dependencies. Remember to press ‘Y’ when prompted to confirm the installation.
Installing ejabberd Using YUM
If you’re using a RHEL-based distribution, you can install ejabberd using the YUM package manager. The steps are similar to the APT installation:
- Update your package lists:
sudo yum update
# Output:
# 'Loaded plugins: fastestmirror, ovl'
# 'Determining fastest mirrors'
# ' * base: mirror.trouble-free.net'
# ' * extras: mirror.trouble-free.net'
# ' * updates: mirror.trouble-free.net'
# 'Resolving Dependencies'
# 'There are unfinished transactions remaining. You might consider running yum-complete-transaction, or "yum-complete-transaction --cleanup-only" and "yum history redo last", first to finish them.'
# 'The program yum-complete-transaction is found in the yum-utils package.'
- Install ejabberd:
sudo yum install ejabberd
# Output:
# 'Loaded plugins: fastestmirror, ovl'
# 'Loading mirror speeds from cached hostfile'
# ' * base: mirror.trouble-free.net'
# ' * extras: mirror.trouble-free.net'
# ' * updates: mirror.trouble-free.net'
# 'Resolving Dependencies'
# 'There are unfinished transactions remaining. You might consider running yum-complete-transaction, or "yum-complete-transaction --cleanup-only" and "yum history redo last", first to finish them.'
# 'The program yum-complete-transaction is found in the yum-utils package.'
The above commands will update your package lists and install ejabberd along with its dependencies. Remember to press ‘Y’ when prompted to confirm the installation.
Now, you have ejabberd installed on your Linux system. You can verify the installation by running the following command:
ejabberdctl status
# Output:
# 'The node ejabberd@localhost is started with status: started'
# 'ejabberd 19.2 is running in that node'
The ejabberdctl status
command checks the status of the ejabberd server. If the installation was successful, it should report that the server is running.
Installing ejabberd from Source
Perhaps you need to install a specific version of ejabberd, or maybe your distribution doesn’t provide a pre-compiled package. In these cases, you can compile and install ejabberd from source. Here’s how:
- First, install the necessary dependencies:
sudo apt-get install build-essential erlang libexpat1-dev libyaml-dev openssl libssl-dev
# Output:
# 'Reading package lists... Done'
# 'Building dependency tree'
# 'Reading state information... Done'
# 'build-essential is already the newest version (12.4ubuntu1).'
# 'build-essential set to manually installed.'
# 'The following additional packages will be installed:'
# ' erlang-base erlang-crypto erlang-ejabberd erlang-inets'
# ' erlang-mnesia erlang-os-mon erlang-xmerl'
# 'Suggested packages:'
# ' erlang erlang-manpages ejabberd-contrib'
# 'The following NEW packages will be installed:'
# ' erlang-asn1 erlang-base erlang-crypto erlang-ejabberd erlang-inets'
# ' erlang-mnesia erlang-os-mon erlang-xmerl'
# '0 upgraded, 8 newly installed, 0 to remove and 31 not upgraded.'
# 'Need to get 22.8 MB of archives.'
# 'After this operation, 30.6 MB of additional disk space will be used.'
# 'Do you want to continue? [Y/n] Y'
- Next, download the ejabberd source code from the official website:
wget https://github.com/processone/ejabberd/archive/refs/tags/21.04.tar.gz
# Output:
# 'Saving to: ‘21.04.tar.gz’'
- Extract the downloaded file and navigate into the extracted directory:
tar xvf 21.04.tar.gz
cd ejabberd-21.04/
# Output:
# 'ejabberd-21.04/'
- Compile and install ejabberd:
./autogen.sh
./configure --enable-user=ejabberd --enable-mysql
make
sudo make install
# Output:
# 'checking for a BSD-compatible install... /usr/bin/install -c'
# 'checking whether build environment is sane... yes'
# 'checking for a thread-safe mkdir -p... /bin/mkdir -p'
# 'checking for gawk... no'
# 'checking for mawk... mawk'
# 'checking whether make sets $(MAKE)... yes'
# 'checking whether make supports nested variables... yes'
# 'checking for gcc... gcc'
# 'checking whether the C compiler works... yes'
# 'checking for C compiler default output file name... a.out'
# 'checking for suffix of executables... '
# 'checking whether we are cross compiling... no'
# 'checking for suffix of object files... o'
# 'checking whether we are using the GNU C compiler... yes'
# 'checking whether gcc accepts -g... yes'
# 'checking for gcc option to accept ISO C89... none needed'
# 'checking whether gcc understands -c and -o together... yes'
# 'checking for style of include used by make... GNU'
# 'checking dependency style of gcc... gcc3'
# 'checking for erl... /usr/local/bin/erl'
# 'checking for erlc... /usr/local/bin/erlc'
# 'checking for erl... /usr/local/bin/erl'
# 'checking for erlc... /usr/local/bin/erlc'
# 'checking Erlang/OTP version... ok'
# 'checking for Erlang/OTP root directory... /usr/local/lib/erlang'
# 'checking for escript... /usr/local/bin/escript'
# 'checking for ct_run... /usr/local/bin/ct_run'
# 'checking for erl... /usr/local/bin/erl'
# 'checking for erlc... /usr/local/bin/erlc'
# 'checking for epmd... epmd'
# 'configure: creating ./config.status'
# 'config.status: creating vars.config'
# 'config.status: creating src/ejabberd.app.src'
# 'config.status: creating Makefile'
# 'config.status: creating src/Makefile'
# 'config.status: creating test/Makefile'
# 'config.status: creating sql/Makefile'
# 'config.status: creating doc/Makefile'
# 'config.status: creating doc/dev/Makefile'
# 'config.status: creating doc/user-guide/Makefile'
# 'config.status: creating doc/tutorials/Makefile'
# 'config.status: creating doc/Makefile'
# 'config.status: creating doc/dev/Makefile'
# 'config.status: creating doc/user-guide/Makefile'
# 'config.status: creating doc/tutorials/Makefile'
# 'config.status: creating src/ejabberd.app.src'
# 'config.status: creating vars.config'
# 'config.status: creating Makefile'
# 'config.status: creating src/Makefile'
# 'config.status: creating test/Makefile'
# 'config.status: creating sql/Makefile'
# 'config.status: creating doc /Makefile'
# 'config.status: creating doc/dev/Makefile'
# 'config.status: creating doc/user-guide/Makefile'
# 'config.status: creating doc/tutorials/Makefile'
This will compile and install ejabberd on your system. The --enable-user=ejabberd
option tells the script to run ejabberd as the ‘ejabberd’ user, and the --enable-mysql
option enables MySQL support.
Installing Different ejabberd Versions
Different versions of ejabberd may contain different features, bug fixes, and improvements. You might need to install a specific version to meet your application’s requirements. Here’s how to install different versions of ejabberd from source and using package managers.
Installing Different Versions from Source
To install a specific version of ejabberd from source, you need to download the corresponding source code from the official website. For example, to install ejabberd 20.07, you would download the 20.07.tar.gz
file instead of 21.04.tar.gz
.
Installing Different Versions Using APT and YUM
If you’re using a package manager, you can specify the version number when installing ejabberd. However, the available versions depend on your distribution’s repositories. Here’s an example using APT:
sudo apt-get install ejabberd=20.07-1
# Output:
# 'Reading package lists... Done'
# 'Building dependency tree'
# 'Reading state information... Done'
# 'E: Version ‘20.07-1’ for ‘ejabberd’ was not found'
In this case, the 20.07-1
version is not available in the repositories. You would need to add a repository that contains the desired version or install it from source.
Version Comparison
Different versions of ejabberd can have significant differences. Here’s a brief overview of some of the changes in recent versions:
Version | Key Changes |
---|---|
21.04 | Added support for Elixir 1.11, improved clustering, and numerous bug fixes. |
20.07 | Added support for OTP 23, improved multi-user chat, and several bug fixes. |
20.04 | Added new configuration options, improved database support, and various bug fixes. |
Using Docker to Install ejabberd
While traditional installation methods have their advantages, containerization is an increasingly popular alternative. It provides a consistent and reproducible environment, which can simplify both development and deployment. Docker is one of the most popular containerization technologies, and it supports ejabberd.
ejabberd Installation Using Docker
Docker allows you to run ejabberd in an isolated environment with its own set of dependencies. Here’s how to install ejabberd using Docker:
- First, pull the ejabberd/ecs image from Docker Hub:
sudo docker pull ejabberd/ecs
# Output:
# 'Using default tag: latest'
# 'latest: Pulling from ejabberd/ecs'
# 'Digest: sha256:4b6aee6b4e8d291231d2712b105033b29de12263b8d28c8f6bf8e3bc98b4e17c'
# 'Status: Image is up to date for ejabberd/ecs:latest'
# 'docker.io/ejabberd/ecs:latest'
- Then, run the image in a new container:
sudo docker run -d --name my-ejabberd -p 5222:5222 ejabberd/ecs
# Output:
# '0a1b103e8c0f3e2399b6854b8e8fb0999cc8a18e8b79ea74a9e6b26007ea80e2'
The above commands will pull the ejabberd/ecs image from Docker Hub and run it in a new container named ‘my-ejabberd’. The -p 5222:5222
option forwards the container’s 5222 port (the default XMPP port) to the host’s 5222 port.
Benefits and Drawbacks of Docker
Using Docker to install ejabberd has several advantages:
- Isolation: Docker runs ejabberd in an isolated environment, which can prevent conflicts with other software on your system.
- Reproducibility: You can easily reproduce the exact same environment on another system by using the same Docker image.
- Simplicity: Docker abstracts away many of the complexities of managing dependencies and configurations.
However, Docker also has some drawbacks:
- Overhead: Running ejabberd in a Docker container can consume more resources than running it directly on your system.
- Complexity: While Docker simplifies many tasks, it can also introduce its own complexities, especially for users unfamiliar with containerization.
Other Containerization Technologies
While Docker is the most popular containerization technology, there are other options like Podman and LXC. These alternatives can provide similar benefits and may be preferable in certain scenarios, depending on your specific needs and constraints.
In conclusion, while traditional installation methods are perfectly valid and useful, containerization technologies like Docker offer compelling alternatives. They can provide isolation, reproducibility, and simplicity, making them worth considering for your ejabberd installation.
Basic Usage and Verification
Once you’ve installed ejabberd, you can start using it to build your messaging application. Here’s an example of how to start the ejabberd server:
ejabberdctl start
# Output:
# 'The node ejabberd@localhost is started with status: started'
# 'ejabberd 21.04 is running in that node'
The ejabberdctl start
command starts the ejabberd server. If the server starts successfully, it should report that the server is running.
You can also verify that ejabberd is installed and running correctly using the status
command:
ejabberdctl status
# Output:
# 'The node ejabberd@localhost is started with status: started'
# 'ejabberd 21.04 is running in that node'
The ejabberdctl status
command checks the status of the ejabberd server. If the server is running, it should report that the server is started and display the running version.
Troubleshooting ejabberd Installations
While the installation of ejabberd on Linux is generally straightforward, you may encounter some issues. Let’s discuss a few common problems and their solutions.
Issue 1: Missing Dependencies
When installing ejabberd, you might encounter errors about missing dependencies. This usually happens if you’re installing from source. Here’s an example of such an error:
sudo ./configure
# Output:
# 'configure: error: "Cannot find erl in your path, please ensure Erlang is installed"
In this case, the installation script couldn’t find the erl
command, which is part of Erlang. The solution is to install the missing dependencies. On Debian-based distributions, you can use the following command:
sudo apt-get install erlang
# Output:
# 'Reading package lists... Done'
# 'Building dependency tree'
# 'Reading state information... Done'
# 'The following additional packages will be installed:'
# ' erlang-base erlang-crypto erlang-ejabberd erlang-inets'
# ' erlang-mnesia erlang-os-mon erlang-xmerl'
# 'Suggested packages:'
# ' erlang erlang-manpages ejabberd-contrib'
# 'The following NEW packages will be installed:'
# ' erlang-asn1 erlang-base erlang-crypto erlang-ejabberd erlang-inets'
# ' erlang-mnesia erlang-os-mon erlang-xmerl'
# '0 upgraded, 8 newly installed, 0 to remove and 31 not upgraded.'
# 'Need to get 22.8 MB of archives.'
# 'After this operation, 30.6 MB of additional disk space will be used.'
# 'Do you want to continue? [Y/n] Y'
Issue 2: Configuration Errors
Another common issue is configuration errors. These can occur if you’ve made a mistake in the ejabberd configuration file. Here’s an example of a configuration error:
ejabberdctl start
# Output:
# 'Crash dump is being written to: erl_crash.dump...done'
# 'Problem starting the ejabberd application: Check for error messages with: ejabberdctl log'
In this case, the ejabberdctl start
command failed to start ejabberd due to a configuration error. You can check the ejabberd log for more details:
ejabberdctl log
# Output:
# '2022-01-01 00:00:00.000 [critical] <0.38.0>@gen_mod:validate_opts:280 Invalid value "mysql" for option 'auth_method' in module 'mod_auth_internal' (available: [internal])'
In this example, the log indicates an invalid value for the auth_method
option in the mod_auth_internal
module. The solution is to fix the error in the ejabberd configuration file.
Issue 3: Permission Errors
You might also encounter permission errors, especially if you’re trying to run ejabberd as a non-root user. Here’s an example:
ejabberdctl start
# Output:
# 'Error: cannot open file /var/lib/ejabberd/.erlang.cookie for writing'
In this case, the ejabberdctl start
command tried to write to a file in a directory owned by root, resulting in a permission error. The solution is to run the command with sudo:
sudo ejabberdctl start
# Output:
# 'The node ejabberd@localhost is started with status: started'
# 'ejabberd 21.04 is running in that node'
In conclusion, while installing ejabberd on Linux is usually a smooth process, you might encounter issues related to missing dependencies, configuration errors, and permission errors. The solutions are usually straightforward: install the missing dependencies, fix the configuration, or adjust the permissions.
Understanding XMPP Servers
The Extensible Messaging and Presence Protocol (XMPP) is an open-standard communications protocol for message-oriented middleware based on XML. XMPP servers are the powerhouses behind many instant messaging, presence information, and contact list maintenance services.
XMPP servers facilitate real-time communication between two endpoints in a network. They are designed to handle a high volume of messages, making them a crucial component in building scalable messaging applications.
The Role of ejabberd in Scalable Messaging Applications
Ejabberd is a robust XMPP server written in the Erlang/OTP language, known for its concurrency, distribution, and fault tolerance capabilities. These attributes make ejabberd an ideal choice for building scalable messaging applications.
Ejabberd’s architecture is designed to handle a large number of users concurrently. It can be distributed across multiple machines, which allows it to scale horizontally to support even larger user bases. Moreover, ejabberd has built-in support for clustering, enabling it to provide high availability and reliability.
To illustrate the power of ejabberd, let’s consider a simple example of sending a message from one user to another:
ejabberdctl send_message_chat admin@localhost user1@localhost 'Hello, User1!'
# Output:
# 'Message sent'
In this example, the send_message_chat
command sends a message from the ‘admin’ user to the ‘user1’ user. The command returns a confirmation that the message was sent. This simple interaction demonstrates ejabberd’s capability to handle messages efficiently.
Overall, the combination of XMPP servers and ejabberd provides a robust foundation for building scalable messaging applications. Understanding these fundamentals is key to effectively installing, configuring, and using ejabberd on Linux.
Project Usages with ejabberd
The scalability and robustness of ejabberd make it an excellent choice for larger projects. Its ability to handle a high volume of messages and its support for clustering allow it to accommodate a growing user base. With ejabberd, you can build applications that not only handle instant messaging but also provide presence information and maintain contact lists.
For instance, if you were to build a social networking application, ejabberd could manage the instant messaging feature. Here’s an example of how to send a broadcast message to all connected users:
ejabberdctl send_message_broadcast admin@localhost 'Hello, everyone!'
# Output:
# 'Message sent'
In this example, the send_message_broadcast
command sends a message from the ‘admin’ user to all connected users. The command returns a confirmation that the message was sent. This feature can be particularly useful in applications where system-wide announcements are necessary.
Exploring XMPP Protocols and More
While ejabberd is a powerful XMPP server, it’s also beneficial to explore related concepts like XMPP protocols and other messaging servers. Understanding XMPP protocols can help you design more efficient messaging applications, while exploring other messaging servers can provide you with a broader perspective on available tools and technologies.
Further Resources for Mastering ejabberd and XMPP
To deepen your understanding of ejabberd and XMPP, here are some resources that you might find helpful:
- The XMPP Standards Foundation: This is the official website of the XMPP Standards Foundation, which provides comprehensive information about XMPP protocols.
The ejabberd official documentation: This is the official documentation of ejabberd, which provides detailed instructions on how to install, configure, and use ejabberd.
The Real-Time Web with XMPP on Class Central – A course by Jack Moffitt on utilizing XMPP for real-time web applications.
Recap: Ejabberd Setup on Linux
In this comprehensive guide, we’ve explored the process of installing and using ejabberd, a robust and scalable XMPP server, on Linux systems. We’ve covered everything from the basic installation to advanced use cases, providing you with the knowledge you need to get ejabberd up and running on your Linux machine.
We began with the basics, walking you through the process of installing ejabberd on Linux using both APT and YUM package managers. We then delved into more advanced topics, discussing how to install ejabberd from source and how to install specific versions of the software.
We also explored alternative approaches to ejabberd installation, such as using Docker and other containerization technologies. Along the way, we tackled common issues you might encounter during the installation and usage of ejabberd, providing you with solutions and workarounds for each problem.
Here’s a quick comparison of the installation methods we’ve discussed:
Method | Complexity | Flexibility | Isolation |
---|---|---|---|
Package Manager (APT/YUM) | Low | Moderate | Low |
From Source | High | High | Low |
Docker | Moderate | High | High |
Whether you’re just starting out with ejabberd or you’re looking to level up your XMPP server skills, we hope this guide has given you a deeper understanding of ejabberd and its installation process.
With its robustness and scalability, ejabberd is a powerful tool for building messaging applications. Now, you’re well-equipped to install and use ejabberd on your Linux system. Happy coding!