How To Install Erlang on Rocky Linux 8 with Easy Steps

Posted on

How To Install Erlang on Rocky Linux 8 with Easy Steps

In this guide, we aim to provide a comprehensive walkthrough on How To Install Erlang on Rocky Linux 8. Erlang is a functional programming language that has significantly influenced programming language design. It remains widely used today. It’s a dynamically typed language renowned for its capabilities in concurrency, distributed programs, and fault tolerance. A notable feature of Erlang is its support for hot swapping, enabling code changes without system interruption.

You can proceed with the following steps to set up the Erlang Programming Language on Rocky Linux 8.

To follow this guide, you should be logged in to your server as a non-root user with sudo privileges. If you need assistance with this, refer to our guide on Initial Server Setup with Rocky Linux 8.

In this article, we’ll initially use the Erlang packagecloud repository to demonstrate how How To Install Erlang on Rocky Linux 8.

1. Install Erlang Programming Language on Rocky Linux 8

First, update your local package index using the following command:

sudo dnf update -y

Next, install the Erlang PackageCloud Yum repository with this command:

curl -s https://packagecloud.io/install/repositories/rabbitmq/erlang/script.rpm.sh | sudo bash
install the Erlang PackageCloud Yum repository

Now, execute the following command to install the Erlang programming language on your server:

sudo dnf install erlang -y

Once the installation is complete, you can proceed to test your Erlang installation.

2. Create a sample project with Erlang

Now, you will verify the Erlang installation by creating a simple "Hello World" project.

First, create a file named hello.erl using your preferred text editor. Here, we use vi:

sudo vi hello.erl

Add the following code to the file:

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

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

Save and close the file.

Next, compile the program from the Erlang shell.

To access the Erlang shell on Rocky Linux 8, use the following command:

erl
**Output**
Erlang/OTP 25 [erts-13.0.4] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:1] [jit:ns]

Eshell V13.0.4  (abort with ^G)
1>

Then, run these commands within the Erlang shell:

**1>** c(hello).
{ok,hello}
**2>** hello:helloworld().
Hello from OrcaCore, Erlang World!
ok

To exit the Erlang shell, type:

**3>** q().

For further information, consult the Erlang Documentation page.

Conclusion

In summary, How To Install Erlang on Rocky Linux 8 is relatively straightforward. This method involves enabling the Erlang Solutions repository and using the system’s package manager. By adding the repository, you ensure access to the latest stable version. After installation, Erlang is ready for development or running applications like RabbitMQ, making Rocky Linux 8 a suitable platform for Erlang-based systems.

Hopefully, you found this helpful. You might also find these articles interesting:

  • How To Set Up CloudLinux on CentOS
  • How To Install Webmin on CentOS 7
  • Install Erlang on Ubuntu 22.04
  • Install RabbitMQ on Ubuntu 24.04

FAQs

How do I verify that Erlang is installed correctly?

Run erl in the terminal. If the Erlang shell starts and shows the version, it’s installed correctly. You can exit by typing q()..

Is Erlang compatible with Rocky Linux 8 for production use?

Absolutely. Erlang runs well on Rocky Linux 8 and is suitable for production environments, especially when used with tools like RabbitMQ or CouchDB.

Does Erlang require any firewall or port configurations?

Erlang-based systems like RabbitMQ may require open ports (e.g., 4369, 5672). Configure firewalls accordingly depending on your use case.

Alternative Methods for Installing Erlang on Rocky Linux 8

While the packagecloud repository method is convenient, here are two alternative methods to How To Install Erlang on Rocky Linux 8: using the official Erlang Solutions repository directly, or compiling from source.

1. Using the Official Erlang Solutions Repository

This method involves adding the Erlang Solutions repository to your system’s package manager configuration and then installing Erlang. This ensures you receive updates directly from the Erlang Solutions team.

Explanation:

Erlang Solutions provides official repositories for various Linux distributions. By adding this repository, you are essentially telling your package manager where to find the Erlang packages. This method offers a good balance between ease of use and direct access to official releases.

Steps:

  1. Download and Install the Erlang Solutions Repository Package:

    First, download the Erlang Solutions RPM package:

    wget https://packages.erlang-solutions.com/erlang-solutions-2.0-1.noarch.rpm

    Then, install the package:

    sudo rpm -Uvh erlang-solutions-2.0-1.noarch.rpm
  2. Install Erlang:

    Now that the repository is configured, you can install Erlang using dnf:

    sudo dnf install erlang -y

This process achieves the same outcome as the packagecloud method but uses the official Erlang Solutions repository, offering potential advantages in terms of direct updates and stability.

2. Compiling Erlang from Source

This method is more involved but gives you the most control over the installation process. It allows you to customize the build options and ensure you are using the exact version you need.

Explanation:

Compiling from source means downloading the Erlang source code and building the executable files yourself. This requires more technical expertise but allows for greater customization and control over the installation. It’s particularly useful if you need specific build options or are working in an environment with limited package management capabilities.

Steps:

  1. Install Dependencies:

    Before compiling, you need to install the necessary build tools and libraries. This typically includes a C compiler (like GCC), make, and other development libraries.

    sudo dnf install gcc glibc-devel make ncurses-devel openssl-devel perl autoconf -y
  2. Download the Erlang Source Code:

    Download the source code from the Erlang official website or GitHub.

    wget https://erlang.org/download/otp_26.0.tar.gz  # Replace with the desired version
    tar -xzf otp_26.0.tar.gz
    cd otp_26.0
  3. Configure and Compile Erlang:

    Now, configure the build process using the configure script. You can specify various options during configuration.

    ./configure --prefix=/usr/local/erlang  # Or your preferred installation directory

    Then, compile the code:

    make

    Finally, install Erlang:

    sudo make install
  4. Set Environment Variables:

    To use Erlang, you need to set the PATH environment variable to include the Erlang binaries. Add the following line to your ~/.bashrc or ~/.bash_profile file:

    export PATH=$PATH:/usr/local/erlang/bin

    Then, source the file:

    source ~/.bashrc  # Or source ~/.bash_profile

Code Example (Configuration Options):

The ./configure script accepts numerous options. For example, to enable HiPE (High-Performance Erlang), you would use:

./configure --prefix=/usr/local/erlang --enable-hipe

To disable specific applications, you can use --without-<application>. For example, to exclude the odbc application:

./configure --prefix=/usr/local/erlang --without-odbc

Compiling from source offers the ultimate control over the Erlang installation, allowing you to tailor it precisely to your needs. However, it requires more technical knowledge and can be more time-consuming. Choose the method that best suits your requirements and technical expertise. This provides flexibility when deciding How To Install Erlang on Rocky Linux 8.