如何在 Ubuntu Linux 上安装最新的 Erlang
Erlang
![](/data/attachment/album/202103/07/001753blfwcg2gc2c2lcgl.jpg)


[Erlang](https://www.erlang.org/) 是一种用于构建大规模可扩展实时系统的函数式编程语言。Erlang 最初是由 [爱立信](https://www.ericsson.com/en) 创建的专有软件，后来被开源。


Erlang 在 [Ubuntu 的 Universe 仓库](https://itsfoss.com/ubuntu-repositories/) 中可用。启用该仓库后，你可以使用下面的命令轻松安装它：



```
sudo apt install erlang
```

![](/data/attachment/album/202103/07/001849jr58abgngdpa0080.png)


但是，*Ubuntu 仓库提供的 Erlang 版本可能不是最新的*。


如果你想要 Ubuntu 上最新的 Erlang 版本，你可以添加 [Erlang Solutions 提供的](https://www.erlang-solutions.com/downloads/)仓库。它们为各种 Linux 发行版、Windows 和 macOS 提供了预编译的二进制文件。


如果你之前安装了一个名为 `erlang` 的包，那么它将会被升级到由添加的仓库提供的较新版本。


### 在 Ubuntu 上安装最新版本的 Erlang


你需要[在 Linux 终端下载密钥文件](https://itsfoss.com/download-files-from-linux-terminal/)。你可以使用 `wget` 工具，所以请确保你已经安装了它：



```
sudo apt install wget

```

接下来，使用 `wget` 下载 Erlang Solution 仓库的 GPG 密钥，并将其添加到你的 apt 打包系统中。添加了密钥后，你的系统就会信任来自该仓库的包。



```
wget -O- https://packages.erlang-solutions.com/ubuntu/erlang_solutions.asc | sudo apt-key add -

```

现在，你应该在你的 APT `sources.list.d` 目录下为 Erlang 添加一个文件，这个文件将包含有关仓库的信息，APT 包管理器将使用它来获取包和未来的更新。


对于 Ubuntu 20.04（和 Ubuntu 20.10），使用以下命令：



```
echo "deb https://packages.erlang-solutions.com/ubuntu focal contrib" | sudo tee /etc/apt/sources.list.d/erlang-solution.list

```

我知道上面的命令提到了 Ubuntu 20.04 focal，但它也适用于 Ubuntu 20.10 groovy。


对于 **Ubuntu 18.04**，使用以下命令：



```
echo "deb https://packages.erlang-solutions.com/ubuntu bionic contrib" | sudo tee /etc/apt/sources.list.d/erlang-solution.list

```

你必须更新本地的包缓存，以通知它关于新添加的仓库的包。



```
sudo apt update

```

你会注意到，它建议你进行一些升级。如果你列出了可用的升级，你会在那里找到 erlang 包。要更新现有的 erlang 版本或重新安装，使用这个命令：



```
sudo apt install erlang

```

安装好后，你可以测试一下。


![](/data/attachment/album/202103/07/001850mkrh478m99m47trr.png)


要退出 Erlang shell，使用 `Ctrl+g`，然后输入 `q`，由于我从来没有用过 Erlang，所以我只好尝试了一些按键，然后发现了操作方法。


#### 删除 erlang


要删除该程序，请使用以下命令：



```
sudo apt remove erlang

```

还会有一些依赖关系。你可以用下面的命令删除它们：



```
sudo apt autoremove

```

如果你愿意，你也可以删除添加的仓库文件。



```
sudo rm /etc/apt/sources.list.d/erlang-solution.list

```

就是这样。享受在 Ubuntu Linux 上使用 Erlang 学习和编码的乐趣。




---


via: <https://itsfoss.com/install-erlang-ubuntu/>


作者：[Abhishek Prakash](https://itsfoss.com/author/abhishek/) 选题：[lujun9972](https://github.com/lujun9972) 译者：[geekpi](https://github.com/geekpi) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
![Warp Terminal](/assets/images/warp-terminal.webp)


![Warp Terminal](/assets/images/warp-terminal.webp)

[Erlang](https://www.erlang.org/) is a functional programming language for building massive scalable real-time systems. Originally created by [Ericsson](https://www.ericsson.com/en) as a proprietary software, Erlang was later open sourced.

Erlang is available in the [Universe repository of Ubuntu](https://itsfoss.com/ubuntu-repositories/). With that repository enabled, you can easily install it using the following command:

`sudo apt install erlang`


![Install Erlang Ubuntu](https://itsfoss.com/content/images/wordpress/2021/02/install-erlang-ubuntu-800x445.png)

However, the *Erlang version offered by Ubuntu repositories may not be the latest*.

If you want the **latest Erlang version on Ubuntu**, you have two ways:

- Use a PPA maintained by RabbitMQ team
- Add the repository
[offered by Erlang Solutions](https://www.erlang-solutions.com/downloads/)

If you had installed a package named `erlang`

previously, it will be upgraded to the newer version offered by the added repository.

## Method 1: Install the latest Erlang using PPA

The good thing is that the [RabbitMQ team maintains a PPA](https://launchpad.net/~rabbitmq/+archive/ubuntu/rabbitmq-erlang) that lets you easily install the latest version of Erlang on Ubuntu-based distributions.

This is valid for Ubuntu 22.04 and 20.04.

Open a terminal and use the following commands one by one:

```
sudo add-apt-repository ppa:rabbitmq/rabbitmq-erlang
sudo apt update
sudo apt install erlang
```


If you already have Erlang installed from Ubuntu's repositories, it will be upgraded to the version provided by the PPA.

### Remove Erlang and the PPA

To uninstall the Erlang version removed from the PPA and move it back to the version provided by the Ubuntu repositories, use PPA Purge.

```
sudo apt install ppa-purge
sudo ppa-purge ppa:rabbitmq/rabbitmq-erlang
```


You can remove Erlang completely instead of downgrading it with:

`sudo apt remove erlang`


[What is PPA Purge? How to Use it in Ubuntu?PPA Purge not only disables a PPA from the system but also reverts the packages it installed to their official version. Learn more about it.](https://itsfoss.com/ppa-purge/)![](https://itsfoss.com/content/images/wordpress/2021/02/ppa-purge.png)


![](https://itsfoss.com/content/images/wordpress/2021/02/ppa-purge.png)

## Method 2: Installing the latest version of Erlang on Ubuntu 20.04 and 18.04

Erlang developers provide prebuilt binaries for various Linux distributions, Windows and macOS.

You’ll need to [download the key file in Linux terminal](https://itsfoss.com/download-files-from-linux-terminal/). You can use wget tool for that so make sure that you have it installed:

`sudo apt install wget`


Next, use wget to download the GPG key of the Erlang Solution repository and add it your apt packaging system. With the key added, your system will trust the packages coming from the repository.

`wget -O- https://packages.erlang-solutions.com/ubuntu/erlang_solutions.asc | sudo apt-key add -`


Now, you should add a file for Erlang in your APT sources.list.d directory. This file will contain the information about the repository and the APT package manager will use it for getting the packages and any future updates to it.

**For Ubuntu 20.04 (and Ubuntu 20.10) **use the following:

`echo "deb https://packages.erlang-solutions.com/ubuntu focal contrib" | sudo tee /etc/apt/sources.list.d/erlang-solution.list`


I know that the above command mentions focal (for Ubuntu 20.04) but it also works for Ubuntu 20.10 groovy.

For **Ubuntu 18.04**, use the following:

`echo "deb https://packages.erlang-solutions.com/ubuntu bionic contrib" | sudo tee /etc/apt/sources.list.d/erlang-solution.list`


You must update the local package cache to inform it about the packages from the newly added repository:

`sudo apt update`


You’ll notice that it suggests several upgrades. If you list the available upgrades, you’ll find erlang packages there. To update the existing erlang version or install it afresh, use this command:

`sudo apt install erlang`


Once installed, you can test it out.

![erlang shell](https://itsfoss.com/content/images/wordpress/2021/02/erlang-shell-800x274.png)

To quit the Erlang shell, use Ctrl+g and then enter q. I had to do a hit and try to figure that out because I had never used Erlang before.

### Removing Erlang

To remove the program, use the following command:

`sudo apt remove erlang`


There will be a few dependencies left. You can remove them with the following command:

`sudo apt autoremove`


If you want, you may also remove the added repository file:

`sudo rm /etc/apt/sources.list.d/erlang-solution.list`


That’s about it. Enjoy learning and coding with Erlang on Ubuntu Linux.