Skip to content

Instantly share code, notes, and snippets.

@taiansu
Last active March 24, 2019 04:21
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taiansu/5b996677c532b6f02c6ec9e4c7844448 to your computer and use it in GitHub Desktop.
Save taiansu/5b996677c532b6f02c6ec9e4c7844448 to your computer and use it in GitHub Desktop.
Install Elixir and phoenix

Elixir 安装導覧

我們將安裝下列項目:

  1. Elixir
  2. Node.js
  3. Postgresql 資料庫
  4. Phoenix

由於 macOS 及 linux 可以使用 asdf 這個語言版本管理器,所以我們將介紹用它來安裝 elixir 及 nodejs 的方式。而 Windows 則會使用 chocolatey 來安裝。

安裝 Chocolatey

Chocolatey 如同 linux 的 dpkg/apt 或 macOS 上的 Homebrew,是近來很流行的軟體包管理系統。前往 Chocolatey 安裝說明 依步驟安裝。

安裝 Elixir 及 Node.js

打開 "cmd.exe" 輸入以下指令:

C:\> choco install elixir
C:\> choco install nodejs-lts
C:\> choco install postgresql

安裝 Phoenix

一樣在 "cmd.exe" 下,輸入以下指令

C:\> mix do local.hex, local.rebar
C:\> mix archive.install https://github.com/phoenixframework/archives/raw/master/phx_new.ez

這樣就安裝完成了

安裝 asdf

git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.6.3

## Check official website if you're using zsh or fish
echo -e '\n. $HOME/.asdf/asdf.sh' >> ~/.bash_profile
echo -e '\n. $HOME/.asdf/completions/asdf.bash' >> ~/.bash_profile

安裝前置套件及資料庫

macOS

brew install coreutils automake autoconf openssl libyaml readline libxslt libtool unixodbc postgresql pgp wxmac

Ubuntu

sudo apt-get install automake autoconf libreadline-dev libncurses-dev libssl-dev libyaml-dev libxslt-dev libffi-dev libtool unixodbc-dev postgresql

其它 distro 請參考 asdf 官網

安裝 asdf 的 elixir 及 nodejs plugin

Note: 如果你的系統裡已經有 nodejs > 5.5,就不需要用 asdf 管理 nodejs。

// erlang
export KERL_CONFIGURE_OPTIONS="--disable-debug --without-javac"
asdf plugin-add erlang https://github.com/asdf-vm/asdf-erlang.git

// elixir
asdf plugin-add elixir https://github.com/asdf-vm/asdf-elixir.git

// nodejs
asdf plugin-add nodejs https://github.com/asdf-vm/asdf-nodejs.git
bash ~/.asdf/plugins/nodejs/bin/import-release-team-keyring

用 asdf 安裝 Elixir 及 Node.js

asdf list-all erlang # 用最新的那個,目前是 21.3.2
asdf install erlang 21.3.2
asdf global erlang 21.3.2
asdf list-all elixir # 用最新的那個,目前是 1.8.1
asdf install elixir 1.8.1
asdf global elixir 1.8.1
asdf list-all nodejs # 找最新的偶數版(lts)
asdf install nodejs 10.15.3
asdf global nodejs 10.15.3

安裝 Phoenix

mix do local.hex, local.rebar
mix archive.install hex phx_new
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment