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    (安装erlang从github上下载速度比较慢,最好centos 服务器上安装shadowsocks客户端 参考文章:http://www.cnblogs.com/weifeng1463/p/8931254.html)

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:

Install Elixir

Elixir is available in EPEL repository, but it is very outdated. So, in order to install latest version, we will compile and install it from source file.

Please be mindful that before installing Elixir, you must install Erlang first.

Git clone to the Elixir repository:

git clone https://github.com/elixir-lang/elixir.git

The above command will clone the latest version to a folder called elixir in the current working directory. I have

Go to the elixir directory:

cd elixir/

Run the following command to start compiling elixir:

make clean test

Sample output:

[...]
Compiled lib/iex/app.ex
Compiled lib/iex.ex
Compiled lib/iex/autocomplete.ex
Compiled lib/iex/cli.ex
Compiled lib/iex/config.ex
Compiled lib/iex/history.ex
Compiled lib/iex/helpers.ex
Compiled lib/iex/introspection.ex
Compiled lib/iex/remsh.ex
Compiled lib/iex/server.ex
Compiled lib/iex/evaluator.ex
Compiled lib/iex/info.ex
Generated iex app
==> elixir (eunit)
All 194 tests passed. ==> elixir (exunit)
............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. Finished in 126.1 seconds (81.7s on load, 44.3s on tests)
2909 tests, 0 failures Randomized with seed 29478
==> ex_unit (exunit)
.......................................................................................................................................................................................... Finished in 8.0 seconds (6.5s on load, 1.5s on tests)
186 tests, 0 failures Randomized with seed 540622
==> logger (exunit)
........................................................................................ Finished in 4.4 seconds (3.9s on load, 0.4s on tests)
88 tests, 0 failures Randomized with seed 662540
==> mix (exunit)
.................................................................................................................................................................................................................................................................................................................. Finished in 91.0 seconds (14.1s on load, 76.8s on tests)
306 tests, 0 failures Randomized with seed 988584
==> eex (exunit)
....................................................................... Finished in 0.9 seconds (0.8s on load, 0.07s on tests)
71 tests, 0 failures Randomized with seed 955314
==> iex (exunit)
........................................................................................................... Finished in 5.7 seconds (3.3s on load, 2.3s on tests)
107 tests, 0 failures Randomized with seed 128154

If the tests pass, you are done.

Now, It is highly recommended to add Elixir’s bin path to your PATH environment variable. Otherwise, Elixir will not work.

To do so, run the following command:

export PATH="$PATH:/root/elixir/bin"

Here, I have installed elixir on /root/elixir/ location. You must replace this path with your actual Elixir installation path.

Verify Elixir

To verify whether Elixir is installed or not, run:

iex

Sample output:

Erlang/OTP 18 [erts-7.3] [source-d2a6d81] [64-bit] [async-threads:10] [hipe] [kernel-poll:false]

Interactive Elixir (1.3.0-dev) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)>

If you see the Elixir’s shell prompt, congratulations!

Again, to close the Elixir’s shell, just press Ctrl-C twice.

To check Elixir’s version:

elixir --version

Sample output:

Elixir 1.3.0-dev (bbf7a23)

That’s it. We have now successfully setup working Erlang and Elixir development environment in CentOS 7 server.

Cheers!

参考文章:https://www.unixmen.com/install-erlang-elixir-centos-7/

最新文章

  1. C#编程语言与面向对象——核心
  2. MSDN相关下载地址
  3. 解读Unity中的CG编写Shader系列4——unity中的圆角矩形shader
  4. Spring ProxyFactory
  5. CSS- 兼容样式记录
  6. Android(java)学习笔记153:layout_weight使用注意事项
  7. python 递归展开嵌套的序列(生成器用法)
  8. Java中的反射——(1)什么是反射
  9. img转data
  10. tensorflow核心概念和原理介绍
  11. C#图解教程 第二十三章 预处理指令
  12. keras实现简单性别识别(二分类问题)
  13. C# 开源组件--NPOI读取Excel单元格中的公式值
  14. python常见报错类型
  15. 如何用java完成一个中文词频统计程序
  16. MongoDB修改默认数据库
  17. NetCore入门篇:(十二)在IIS中部署Net Core程序
  18. Visual C++的DLL
  19. iOS调用第三方API/Framework
  20. for, while的用法

热门文章

  1. MyBatis报错 Parameter '0' not found. Available parameters are [arg1, arg0, param1, param2]
  2. ubuntu启动脚本一览分析
  3. AC日记——The Child and Sequence codeforces 250D
  4. oracle exp CONSISTENT
  5. LAMP----linux+apache+mysql+php详细安装步骤之一APACHE篇(openldap等)
  6. NAND Flash memory in embedded systems
  7. Persisting iOS Application Data in SQLite Database Using FMDB
  8. 【spring Boot】2.在Myecplise上把spring Boot项目打包 war包和jar包
  9. JAVA常见算法题(五)
  10. 关于使用ueditor时候遇到的情况