How to install Erlang on Rocky Linux/Alma Linux/CentOS 8

Erlang is a functional, general-purpose, concurrent programming language and garbage-collected runtime environment built for concurrency, fault tolerance, and distributed application architectures. It is supported and maintained by Ericsson OTP product unit.

In this guide, we will install Erlang/OTP in a Rocky Linux/Alma Linux/CentOS 8.

Prerequisites

You need the following to follow along

  • Updated Rocky Linux/Alma Linux 8 server
  • Root access or user with root access
  • Internet access from the server

Table of Content

  1. Updating the system
  2. Installing Erlang
  3. Creating Hello world program

1. Updating the system

Let us ensure that our server packages are up to date using this command:

sudo dnf -y update

Let us also install some common packages

sudo dnf install vim -y

2. Installing Erlang

The Erlang package is distributed via Yum repositories on  PackageCloud. Install the PackageCloud Yum repository using this command:
<meta charset="utf-8">curl -s https://packagecloud.io/install/repositories/rabbitmq/erlang/script.rpm.sh | sudo bash

This is the output on my server

$ curl -s https://packagecloud.io/install/repositories/rabbitmq/erlang/script.rpm.sh | sudo bash

Detected operating system as rocky/8.
Checking for curl...
Detected curl...
Downloading repository file: https://packagecloud.io/install/repositories/rabbitmq/erlang/config_file.repo?os=rocky&dist=8&source=script
done.
Installing yum-utils...

Rocky Linux 8 - AppStream                                                                                                       15 kB/s | 4.8 kB     00:00
Rocky Linux 8 - BaseOS                                                                                                         6.5 kB/s | 4.3 kB     00:00
Rocky Linux 8 - Extras                                                                                                          27 kB/s | 3.5 kB     00:00
rabbitmq_erlang-source                                                                                                         1.3 kB/s | 819  B     00:00
rabbitmq_erlang-source                                                                                                          21 kB/s | 3.8 kB     00:00
Importing GPG key 0xDF309A0B:
 Userid     : "https://packagecloud.io/rabbitmq/erlang (https://packagecloud.io/docs#gpg_signing) <support@packagecloud.io>"
 Fingerprint: 2EBD E413 D3CE 5D35 BCD1 5B7C 71C6 3471 DF30 9A0B
 From       : https://packagecloud.io/rabbitmq/erlang/gpgkey
rabbitmq_erlang-source                                                                                                         357  B/s | 296  B     00:00
Package yum-utils-4.0.18-4.el8.noarch is already installed.
Dependencies resolved.
Nothing to do.
Complete!
Generating yum cache for rabbitmq_erlang...
Importing GPG key 0xDF309A0B:
 Userid     : "https://packagecloud.io/rabbitmq/erlang (https://packagecloud.io/docs#gpg_signing) <support@packagecloud.io>"
 Fingerprint: 2EBD E413 D3CE 5D35 BCD1 5B7C 71C6 3471 DF30 9A0B
 From       : https://packagecloud.io/rabbitmq/erlang/gpgkey
Generating yum cache for rabbitmq_erlang-source...

The repository is setup! You can now install packages.

Now we can install erlang from the added repos:

$ sudo dnf install erlang
Last metadata expiration check: 0:00:27 ago on Fri 12 Nov 2021 07:30:53 AM EAT.
Dependencies resolved.
===============================================================================================================================================================
 Package                           Architecture                      Version                                  Repository                                  Size
===============================================================================================================================================================
Installing:
 erlang                            x86_64                            24.1-1.el8                               rabbitmq_erlang                             20 M

Transaction Summary
===============================================================================================================================================================
Install  1 Package

Total download size: 20 M
Installed size: 36 M
Is this ok [y/N]: y
Downloading Packages:
erlang-24.1-1.el8.x86_64.rpm                                                                                                    42 MB/s |  20 MB     00:00
---------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                           41 MB/s |  20 MB     00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                       1/1
  Installing       : erlang-24.1-1.el8.x86_64                                                                                                              1/1
  Running scriptlet: erlang-24.1-1.el8.x86_64                                                                                                              1/1
  Verifying        : erlang-24.1-1.el8.x86_64                                                                                                              1/1

Installed:
  erlang-24.1-1.el8.x86_64

Complete!

3. Creating Hello world program

Create hello.erl file

vim hello.erl

Add this to the file

% This is a test Hello World Erlang Code
-module(hello).
-import(io,[fwrite/1]).
-export([helloworld/0]).

helloworld() ->
   fwrite("Hello from Citizix, Erlang World!\n").

Compile it from the Erlang shell. Don’t forget the full-stop (“period“) at the end of each command:

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

Eshell V12.1  (abort with ^G)
1> c(hello).
{ok,hello}
2> hello:helloworld().
Hello from Citizix, Erlang World!
ok
3>

You have successfully installed Erlang in your system.

Conclusion

Thanks for using this tutorial for installing the Erlang programming language on your Rocky Linux/Alma Linux 8 system. For additional help or useful information, we recommend you to check the official Erlang website.

comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy