在Ubuntu 20.04| 18.04 LTS上安装最新的Erlang
时间:2020-02-23 14:44:42 来源:igfitidea点击:
Erlang是Ericsson OTP产品单元支持和维护的功能,通用,并发编程语言和垃圾收集的运行时环境。
Erlang编程语言是为并发,容错和分布式应用体系结构的。
OTP(Open Telecom平台)是Erlang的库和中间件的集合。
本教程将向我们展示如何在Ubuntu 20.04| 18.04 LTS上安装和使用最新版本的Erlang/OTP
第1步:导入Erlang GPG密钥
运行以下命令以导入erlang存储库GPG密钥:
wget -O- https://packages.erlang-solutions.com/ubuntu/erlang_solutions.asc | sudo apt-key add
第2步:将Erlang存储库添加到Ubuntu 20.04/18.04
导入密钥后,通过运行以下命令将存储库添加到Ubuntu 20.04/18.04系统中:
Ubuntu 20.04:
echo "deb https://packages.erlang-solutions.com/ubuntu focal contrib" | sudo tee /etc/apt/sources.list.d/rabbitmq.list
Ubuntu 18.04:
echo "deb https://packages.erlang-solutions.com/ubuntu bionic contrib" | sudo tee /etc/apt/sources.list.d/rabbitmq.list
第3步:在Ubuntu 20.04| 18.04 LTS上安装Erlang
最后一步是Erlang的实际安装。
更新系统包列表并安装Erlang:
sudo apt update sudo apt install erlang
要启动Erlang Shell,请运行命令:
$erl Erlang/OTP 22 [erts-10.7.1] [source] [64-bit] [smp:1:1] [ds:1:1:10] [async-threads:1] Eshell V10.7.1 (abort with ^G) 1>
shell启动后,打印另一个提示。
我们可以通过编写一个简单的Hello World Erlang代码来测试。
$cat 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 21 [erts-10.1] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:1] Eshell V10.1 (abort with ^G) 1> c(hello). {ok,hello}
然后从erlang shell运行程序:
2> hello:helloworld(). Hello, Erlang World! ok 3>