elixir/phonixを動かしてみた
概要
仮想環境(Centos6.6)に Elixir/Phoenixを実行してみるを参考にしてElixir/Phoenixを動かしてみました。
erlang
nodejsは、epelレポジトリからインストールしました。
$ sudo yum install epel-release $ sudo yum install nodejs npm --enablerepo=epel
そのほかは、参考サイトと同じ手順でインストールできました。.bashrcに書き込むコマンドのhomeディレクトリは環境に合わせる必要があります。
$ sudo yum install -y lynx wget curl git nodejs npm redhat-lsb inotify-tools $ git clone https://github.com/robisonsantos/evm.git $ cd evm $ ./install $ echo 'source /homeディレクトリ/.evm/scripts/evm' >> ~/.bashrc $ source ~/.bashrc $ evm list $ evm install OTP_17.5 $ evm use 17.5 default $ erl
elixir
参考サイトと同じ手順でインストールできました。
$ \curl -sSL https://raw.githubusercontent.com/taylor/kiex/master/install | bash -s $ echo 'test -s "$HOME/.kiex/scripts/kiex" && source "$HOME/.kiex/scripts/kiex"' >> ~/.bashrc $ source ~/.bashrc $ kiex list known $ kiex install 1.0.5 $ kiex use 1.0.5 default $ iex
rebar
参考サイトと同じ手順でインストールできました。
$ git clone git://github.com/rebar/rebar.git $ cd rebar $ ./bootstrap $ sudo mv rebar /usr/local/bin/ $ rebar -V rebar 2.6.0 17 20150706_104711 git 2.6.0-14-ge83a214
Phenix
参考サイトの手順に2点はまりポイントがありました。
$ mix local.hex $ mix archive.install https://github.com/phoenixframework/phoenix/releases/download/v0.14.0/phoenix_new-0.14.0.ez $ mix phoenix.new hello_world
依存モジュールをインストールするかどうか聞かれます。noを選択します。hello_worldディレクトリに移動後実行しないとインストールできません。
$ cd hello_world $ mix deps.get $ npm install $ mix phoenix.server
コンパイルエラーが発生します。
== Compilation error on file lib/hello_world/endpoint.ex == ** (CompileError) lib/hello_world/endpoint.ex:1: function router/2 undefined (stdlib) lists.erl:1336: :lists.foreach/2 (stdlib) erl_eval.erl:657: :erl_eval.do_apply/6
lib/hello_world/endpoint.exの37行目を修正します。参考:compile error after update
$ vi lib/hello_world/endpoint.ex plug HelloWorld.Router # plug :router, HelloWorld.Router
ホスト側のブラウザから、http://192.168.33.10:4000/にアクセスする。
ログが出力されます。速いのかどうかわかりません...
1回目
[info] GET / [debug] Processing by HelloWorld.PageController.index/2 Parameters: %{} Pipelines: [:browser] [info] Sent 200 in 31ms [info] GET /favicon.ico
2回目
[info] GET /favicon.ico [info] GET / [debug] Processing by HelloWorld.PageController.index/2 Parameters: %{} Pipelines: [:browser] [info] Sent 200 in 147µs