Install Erlang and Elixir in CentOS 7
In this tutorial, we will be discussing about how to install Erlang and Elixir in CentOS 7 minimal server. Before installing them, let us see a brief explanation of each.
About Erlang
Erlang is an open source 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. It is designed at the Ericsson Computer Science Laboratory.
About Elixir
Elixir is a dynamic, functional language designed for building scalable and maintainable applications. Elixir leverages the Erlang VM, known for running low-latency, distributed and fault-tolerant systems, while also being successfully used in web development and the embedded software domain.
Now, let us start to install Erlang and Elixir in CentOS 7 64bit minimal server.
Prerequisites
Before installing Erlang and Elixir, we need to install the following prerequisites.
yum update
yum install epel-release
yum install gcc gcc-c++ glibc-devel make ncurses-devel openssl-devel autoconf java-1.8.0-openjdk-devel git wget wxBase.x86_64
Install Erlang
The Erlang version in the official repositories might be older. So, let us download and install the latest Erlang version.
Add Erlang official repository to install the latest Erlang.
To do so, head over to the Erlang repository page, and download the repository depending upon the distribution you use:
Since, we are installing Erlang in CentOS 7, I am going to add the following repository.
wget http://packages.erlang-solutions.com/erlang-solutions-1.0-1.noarch.rpm
rpm -Uvh erlang-solutions-1.0-1.noarch.rpm
Update the repository lists with command:
yum update
Install Erlang using command:
yum install erlang
That’s it. The latest Erlang version has been installed.
Verify Erlang
Run the following command to verify whether Erlang is installed or not.
erl
Sample output:
Erlang/OTP 18 [erts-7.3] [source-d2a6d81] [64-bit] [async-threads:10] [hipe] [kernel-poll:false] Eshell V7.3 (abort with ^G) 1>
If you see the Erlang command prompt, it’s working! To close the shell, just press Ctrl-Ctwice.
Test a sample “hello_world” program in Erlang
Create a new file called “hello.erl”.
vi hello.erl
Add the following lines:
-module(hello). -export([hello_world/0]). hello_world() -> io:fwrite("hello, world\n").
Save and close the file.
Enter to Erlang shell with command:
erl
Run the following commands one by one. Don’t forget to add dot (.) at the end of each command:
c(hello).
hello:hello_world().
Sample output: