Install Erlang on Debian 11/Debian 10

|
Last Updated:
|
|

This tutorial provides a step-by-step guide on how to install Erlang on Debian 11/Debian 10. According to erlang.org, Erlang is a programming language used to build massively scalable soft real-time systems with requirements on high availability. Some of its uses are in telecoms, banking, e-commerce, computer telephony and instant messaging. Erlang’s runtime system has built-in support for concurrency, distribution and fault tolerance.

Install Erlang on Debian 11/Debian 10

There are different ways in which you can install Erlang on Debian;

  1. Install Erlang using Prebuilt binaries
  2. Install Erlang by compiling from the source

Install Erlang using Prebuilt binaries

The default debian repositories provides Erlang packages. However, the available packages may not be up-to-date.

Erlang/OTP 24.2.2 is the the current release versions as of this writing.

The default Debian 11 repos provides version 23.2.6;

apt-cache policy erlang
erlang:
  Installed: (none)
  Candidate: 1:23.2.6+dfsg-1
  Version table:
     1:23.2.6+dfsg-1 500
        500 http://deb.debian.org/debian bullseye/main amd64 Packages

The default Debian 10 repos provides version 21.2.6;

apt-cache policy erlang
erlang:
  Installed: (none)
  Candidate: 1:21.2.6+dfsg-1
  Version table:
     1:21.2.6+dfsg-1 500
        500 http://deb.debian.org/debian buster/main amd64 Packages

Install Erlang on Debian 10 using Prebuilt binaries

To install latest release version of Erlang on Debian 10, you first need to install the Erlang repository as follows;

wget https://packages.erlang-solutions.com/erlang-solutions_2.0_all.deb
apt install ./erlang-solutions_2.0_all.deb
apt update
apt install erlang

The Erlang distribution also includes OTP (Open Telecom Platform) which provides a rich set of libraries and applications.

Install Erlang on Debian 11 using Prebuilt binaries

Unfortunately, as of this writing, the default Debian 11 repositories do not provided the latest version of Erlang;

apt-cache policy erlang

Sample output;

erlang:
  Installed: (none)
  Candidate: 1:23.2.6+dfsg-1
  Version table:
     1:23.2.6+dfsg-1 500
        500 http://deb.debian.org/debian bullseye/main amd64 Packages

Thus, download the current release Erlang Debian 11 DEB binary installer from Erlang downloads page.

wget https://packages.erlang-solutions.com/erlang/debian/pool/esl-erlang_24.2.1-1~debian~buster_amd64.deb

Next, install it as follows;

apt install ./esl-erlang_24.2.1-1~debian~buster_amd64.deb

Install Erlang by Compiling from the Source Code

If you want to run the latest version of Erlang on Debian 11/Debian 10, then you can build it from the source.

  • Install Required Build Utilities
apt install zip libncurses-dev sed git tar make gcc perl openssl flex bison default-jdk libssl-dev unixodbc-dev libwxgtk3.0-gtk3-dev libwxgtk-webview3.0-gtk3-dev libglu1-mesa-dev fop xsltproc libxml2-utils apache2 rsync g++
  • Download Erlang Source Code
VER=24.2.2
wget https://github.com/erlang/otp/releases/download/OTP-$VER/otp_src_$VER.tar.gz
  • Extract the Source code
tar xzf otp_src_$VER.tar.gz
  • Configure, build and install Erlang;
cd otp_src_$VER
export ERL_TOP=`pwd`
./configure

Before you can proceed, ensure that the configure script above returns no error.

make

Run smoke test to ensure the build is successful;

make release_tests
cd release/tests/test_server
~/otp_src_24.2.2/bin/erl -s ts install -s ts smoke_test batch -s init stop

Next, access $ERL_TOP/release/tests/test_server/index.html in your web browser and make sure that there are zero failed test cases.

rsync -avP ~/otp_src_24.2.2 /var/www/html/
sed -i 's|/var/www/html|/var/www/html/otp_src_24.2.2/release/tests/test_server/|' /etc/apache2/sites-available/000-default.conf
chown -R www-data: /var/www/html/otp_src_24.2.2/release/tests/test_server
systemctl restart apache2

Access the Web Server, http://<server-IP>.

Install Erlang on Debian 11/Debian 10

Install Erlang from Source on Debian 11/Debian 10 if all well from the test above.

cd ~/otp_src_24.2.2/
make install

Using Erlang

You can now start using Erlang language for your programming.

erl

Check current working directory by running the command pwd().;

Erlang/OTP 24 [erts-12.2.1] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:1] [jit]

Eshell V12.2.1  (abort with ^G)
1> pwd().
/home/kifarunix
ok
2>

You can now start writing your projects in specific directories. For example in the above, I am working from /home/kifarunix directory.

Creating an Hello World program;

cat > hello_world.erl << 'EOL'
-module(hello_world).
   -export([hello_world/0]).

hello_world() ->
    io:fwrite("hello world\n").
EOL

Next, execute the program;

erl
Erlang/OTP 24 [erts-12.2.1] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:1] [jit]

Eshell V12.2.1  (abort with ^G)
1> pwd().
/home/kifarunix
ok
2> c(hello_world).
{ok,hello_world}
3> hello_world:hello_world().
hello world
ok
4>

You can check further examples on Erlang by Example.

Read more on the documentation page.

Other Tutorials

Install RabbitMQ on Debian 11/Debian 10

Install GVM 21.04 on Debian 11/Debian 10

Install ProcessWire on Debian 11

SUPPORT US VIA A VIRTUAL CUP OF COFFEE

We're passionate about sharing our knowledge and experiences with you through our blog. If you appreciate our efforts, consider buying us a virtual coffee. Your support keeps us motivated and enables us to continually improve, ensuring that we can provide you with the best content possible. Thank you for being a coffee-fueled champion of our work!

Photo of author
koromicha
I am the Co-founder of Kifarunix.com, Linux and the whole FOSS enthusiast, Linux System Admin and a Blue Teamer who loves to share technological tips and hacks with others as a way of sharing knowledge as: "In vain have you acquired knowledge if you have not imparted it to others".

Leave a Comment