如何在RHEL 8/CentOS 8上安装最新的Erlang

时间:2020-02-23 14:30:45  来源:igfitidea点击:

如何在RHEL 8/CentOS 8上安装Erlang? Erlang是一种功能通用的并发编程语言,是为并发,容错和分布式应用程序体系结构而构建的垃圾收集运行时环境。它由爱立信OTP产品部门支持和维护。

使用Erlang时,我们经常会听到OTP一词。 OTP(开放电信平台)是Erlang的库和中间件的集合。本指南将介绍在RHEL 8/CentOS 8上安装Erlang/OTP的步骤。

在RHEL 8上安装最新的Erlang | CentOS的8

Github RabbitMQ存储库中提供了Erlang软件包。建议始终安装最新版本,我们可以检查" Erlang RPM版本"页面。

添加YUM存储库:

sudo tee /etc/yum.repos.d/rabbitmq_erlang.repo<<EOF
[rabbitmq_erlang]
name=rabbitmq_erlang
baseurl=https://packagecloud.io/rabbitmq/erlang/el/8/x86_64
repo_gpgcheck=1
gpgcheck=1
enabled=1
# PackageCloud's repository key and RabbitMQ package signing key
gpgkey=https://packagecloud.io/rabbitmq/erlang/gpgkey
       https://dl.bintray.com/rabbitmq/Keys/rabbitmq-release-signing-key.asc
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300

[rabbitmq_erlang-source]
name=rabbitmq_erlang-source
baseurl=https://packagecloud.io/rabbitmq/erlang/el/8/SRPMS
repo_gpgcheck=1
gpgcheck=0
enabled=1
# PackageCloud's repository key and RabbitMQ package signing key
gpgkey=https://packagecloud.io/rabbitmq/erlang/gpgkey
       https://dl.bintray.com/rabbitmq/Keys/rabbitmq-release-signing-key.asc
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
EOF

清理yum缓存并更新:

sudo yum clean all
sudo yum -y makecache

然后在CentOS 8 RHEL 8系统上安装最新版本的Erlang :

sudo yum install erlang

按键盘上的y键开始在CentOS 8 RHEL 8上安装Erlang:

Last metadata expiration check: 0:00:55 ago on Tue 22 Sep 2017 09:50:06 PM UTC.
Dependencies resolved.
==================================================================================================================================================================
 Package                            Architecture                       Version                                  Repository                                   Size
==================================================================================================================================================================
Installing:
 erlang                             x86_64                             23.0.4-1.el8                             rabbitmq_erlang                              25 M

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

Total download size: 25 M
Installed size: 60 M
Is this ok [y/N]: y

通过运行erl命令来确认安装:

$erl
Erlang/OTP 23 [erts-11.0.4] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:1] [hipe]

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

通过编写简单的Hello World Erlang代码进行测试。

$vim hello.erl

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

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

从Erlang Shell进行编译。不要忘记每个命令末尾的句号(句号)。

$erl
Erlang/OTP 22 [erts-10.4.4] [source] [64-bit] [smp:1:1] [ds:1:1:10] [async-threads:1] [hipe]
Eshell V10.4.4  (abort with ^G)
1> c(hello).
{ok,hello}
2>

然后从Erlang shell运行程序:

2> hello:helloworld().
Hello, Erlang World!
ok