linux erlang
时间: 2024-12-26 08:23:22 浏览: 5
### Erlang on Linux Installation and Configuration
#### Installing Erlang Using Package Managers
For most modern Linux distributions, installing Erlang can be straightforward using package managers like `apt` for Debian-based systems or `yum`/`dnf` for Red Hat-based ones.
On a Debian-based system such as Ubuntu:
```bash
sudo apt update && sudo apt install erlang
```
This command updates the local package index with the latest changes made by software developers and installs Erlang[^1].
#### Manually Downloading and Installing Erlang
Alternatively, one might opt to download an official release directly from the Erlang Solutions website. After downloading, extract it into `/usr/local/lib`, set up symbolic links within `/usr/bin`, adjust environment variables including `$PATH` in shell profiles (`~/.bashrc`), and source this file so that these modifications take effect immediately without logging out or restarting the terminal session.
#### Verifying Installation Success
Once installed successfully, verify the version of Erlang running on your machine via:
```bash
erl -version
```
If everything has been configured correctly, this should output information about the currently active Erlang runtime environment along with its specific build details[^2].
#### Configuring Environment Variables Permanently
To ensure all users have access to Erlang commands regardless of their current working directory, add paths pointing towards binaries provided by Erlang distribution permanently through editing global profile files located at `/etc/profile.d/`.
Create a new script named `erlang.sh` inside this folder containing lines similar to below:
```bash
export PATH=$PATH:/path/to/your/erlang/bin
```
After saving changes, either reboot the computer or execute `. /etc/profile` to apply them instantly across sessions.
#### Testing Basic Functionality With Hello World Program
Write a simple program called hello.erl:
```erlang
-module(hello).
-export([start/0]).
start() ->
io:fwrite("Hello world\n").
```
Compile it using escript tool included in standard installations:
```bash
escript hello.erl start
```
Upon execution, expect "Hello world" printed onto console indicating proper functioning post-installation setup completion[^3].
阅读全文