在Linux(CentOS、Ubuntu等等)中安装Erlang和Elixir

检查旧版本

$ uname -a
Linux ws-ersyia-0 5.4.241-1-tlinux4-0017.10 #1 SMP Wed May 8 17:01:03 CST 2024 x86_64 x86_64 x86_64 GNU/Linux
➜ /workspace elixir --version
Erlang/OTP 24 [erts-12.3.2.17] [source] [64-bit] [smp:8:2] [ds:8:2:10] [async-threads:1] [jit]
Elixir 1.13.3 (compiled with Erlang/OTP 22)

卸载旧版本

$ where elixir
$ where erl
$ rm -rf /opt/elixir /opt/erlang

下载安装包

$ wget https://github.com/erlang/otp/releases/download/OTP-27.0.1/otp_src_27.0.1.tar.gz
$ wget https://github.com/elixir-lang/elixir/archive/refs/tags/v1.17.2.zip

安装 erlang

$ tar zxvf otp_src_27.0.1.tar.gz
$ cd otp_src_27.0.1
$ ./configure && make && make install
$ erl -s erlang halt
Erlang/OTP 27 [erts-15.0.1] [source] [64-bit] [smp:8:2] [ds:8:2:10] [async-threads:1] [jit:ns]

安装 elixir

$ unzip v1.17.2.zip
$ cd elixir-1.17.2
$ make clean compile
$ ./bin/elixir --version
Erlang/OTP 27 [erts-15.0.1] [source] [64-bit] [smp:8:2] [ds:8:2:10] [async-threads:1] [jit:ns]
Elixir 1.17.2 (compiled with Erlang/OTP 27)

配置 PATH

$ vim ~/.zshrc

添加路径到PATH

export PATH=$PATH:/workspace/elixir-1.17.2/bin

如果要配置文件立即生效,还需要source一下配置文件

$ source ~/.zshrc

查看版本:

$ elixir --version
Erlang/OTP 27 [erts-15.0.1] [source] [64-bit] [smp:8:2] [ds:8:2:10] [async-threads:1] [jit:ns]
Elixir 1.17.2 (compiled with Erlang/OTP 27)

mix ok & install rebar3

配置mix hex和rebar3

$ mix local.hex -y
$ wget https://s3.amazonaws.com/rebar3/rebar3
$ chmod +x ./rebar3
$ ./rebar3 local install
$ vim ~/.zshrc
export PATH=/root/.cache/rebar3/bin:$PATH
$ rebar3 -v
rebar 3.23.0 on Erlang/OTP 27 Erts 15.0.1

如果要配置文件立即生效,还需要source一下配置文件

$ source ~/.zshrc
posted @   MarkHoo  阅读(84)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
点击右上角即可分享
微信分享提示