在CentOS上安装Elixir

环境

操作系统:CentOS 6.7
Erlang R14B04 ⇒ Erlang/OTP 21 [开发版]
Eshell V5.8.5 ⇒ Eshell V9.0.1
Elixir:1.6.0-dev

经过

我在尝试在CentOS上构建Elixir环境时,按照安装方法执行了yum install elixir命令,但却出现了“未找到elixir等”等错误。

# yum install elixir
No package elixir available.
Error: Nothing to do

因此,我从Erlang安装中使用yum install erlang进行了安装。

# yum install erlang
====================================
Install      72 Package(s)
Upgrade       1 Package(s)

Total download size: 57 M
Is this ok [y/N]: y
Downloading Packages:

Installed:
  erlang.x86_64 0:R14B-04.3.el6                                                 
Dependency Installed:
  SDL.x86_64 0:1.2.14-7.el6_7.1                                                 
Dependency Updated:
  libdrm.x86_64 0:2.4.65-2.el6                                                  

Complete!

接下来,我试图从Github上克隆和安装Elixir,但是这次问题出现在Erlang版本太旧而无法安装Elixir。

# git clone https://github.com/elixir-lang/elixir.git

# cd /usr/local/lib/elixir/
# make clean test

cd lib/elixir && "/usr/bin/elixir/rebar" clean

=ERROR REPORT==== 6-Jul-2017::12:17:46 ===
Loading of /usr/bin/elixir/rebar/rebar/ebin/rebar.beam failed: badfile
escript: exception error: undefined function rebar:main/1
  in function  escript:run/2
  in call from escript:start/1
  in call from init:start_it/1
  in call from init:start_em/1

=ERROR REPORT==== 6-Jul-2017::12:17:46 ===
beam/beam_load.c(1365): Error loading module rebar:
  use of opcode 153; this emulator supports only up to 152

make: *** [clean] Error 127

看起来 Erlang 的版本有点旧。

# /usr/bin/erl -v
Erlang R14B04 (erts-5.8.5) [source] [64-bit] [smp:2:2] [rq:2] [async-threads:0] [kernel-poll:false]

Eshell V5.8.5  (abort with ^G)

我遇到了困难,于是我决定尝试从Github的源代码中编译安装最新版本的Erlang和Elixir,具体步骤如下所述。

我没想到最近竟然还需要从源代码编译。

所以,接下来就是正题了。

安装Erlang

git clone https://github.com/erlang/otp.git
cd otp
./otp_build autoconf
./configure
make
make install

默认情况下,erl的符号链接将被创建在/usr/local/bin/目录下,而其实体似乎被安装在/usr/local/lib/erlang目录下。已经安装了最新版本的Erlang。

# /usr/local/bin/erl -v
Erlang/OTP 21 [DEVELOPMENT] [erts-9.0.1] [source-e8a2cae] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V9.0.1  (abort with ^G)

安装Elixir

转到已部署Elixir的/usr/local/lib/elixir目录,并尝试重新安装刚刚从Github克隆的Elixir。

# cd /usr/local/lib/elixir/
# make clean test

虽然可以通过将 ~/.bash_profile 添加路径 /usr/local/lib/elixir/bin 到Elixir,但是为了与刚刚安装的Erlang相匹配,我创建了一个符号链接到 /usr/local/bin。

# cd /usr/local/bin
# ln -s ../lib/elixir/bin/elixir elixir
# ln -s ../lib/elixir/bin/elixirc elixirc
# ln -s ../lib/elixir/bin/iex iex    
# ln -s ../lib/elixir/bin/mix mix

暂时先安装了最新版本的Elixir。

$ iex
Erlang/OTP 21 [DEVELOPMENT] [erts-9.0.1] [source-e8a2cae] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:10] [hipe] [kernel-poll:false]

warning: the VM is running with native name encoding of latin1 which may cause Elixir to malfunction as it expects utf8. Please ensure your locale is set to UTF-8 (which can be verified by running "locale" in your shell)
Interactive Elixir (1.6.0-dev) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> 

关于服务器语言设置的警告已经出现,但就安装而言,暂时还顺利进行着。

广告
将在 10 秒后关闭
bannerAds