Help us understand the problem. What is going on with this article?

Elixir/Phoenixを実行してみる

More than 5 years have passed since last update.

はじめに

 Elixir/Phoenixを覚えたら、向こう数年おいしいごはんを食べられると偉い人たちが言っています。Railsに取って代わる次世代のWeb言語&フレームワークだそうです。楽してご飯を食べてゆきたいエンジニアとしては、スタダせざるを得ませんね。

 参考1:http://qiita.com/HirofumiTamori/items/0dfdbada30c7d8f183fd
 参考2:http://qiita.com/mizchi/items/e38d3f0461fe316021f7

 ということで、rails s的なことをするところまで、簡単に見ていくこととしましょう。尚、以降のコードに関してはcentos6で動作を確認しております。centos7でも動くと思います。デビアンマンは適宜読み替えて下さい。

手順

evm&erlang/OTP

$ 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/sen/.evm/scripts/evm' >> ~/.bashrc
$ source ~/.bashrc
$ evm list
Available Erlang versions on http://www.erlang.org

OTP_18.0
OTP_17.5
OTP_17.4
OTP_17.3
OTP_17.1
OTP_17.0
R16B03


$ evm install OTP_17.5
$ evm use 17.5 default
$ erl
Erlang/OTP 17 [erts-6.4] [source] [64-bit] [smp:2:2] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V6.4  (abort with ^G)

$ cd ../

※ kerlというバージョン管理マネージャーもあるようですが、evmの方がrvmっぽくってrubyエンジニアには向いていると思いました。

kiex/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
Erlang/OTP 17 [erts-6.4] [source] [64-bit] [smp:2:2] [async-threads:10] [hipe] [kernel-poll:false]

Interactive Elixir (1.0.5) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)>

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


$ cd../

phoenix

$ 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
$ cd hello_world
$ mix deps.get
$ npm install
$ mix phoenix.server
[info] Running HelloWorld.Endpoint with Cowboy on http://localhost:4000
06 Jul 19:53:33 - info: compiled 3 files into 2 files, copied 3 in 1580ms

確認

実際にアクセスしてみると、以下のとおりログが出力されることを確認できました。

[info] GET /
[debug] Processing by HelloWorld.PageController.index/2
  Parameters: %{"format" => "html"}
  Pipelines: [:browser]
[info] Sent 200 in 42ms
[error] backend port not found: :inotifywait

[info] GET /favicon.ico
[info] GET /
[debug] Processing by HelloWorld.PageController.index/2
  Parameters: %{"format" => "html"}
  Pipelines: [:browser]
[info] Sent 200 in 534μs

 早い早いと有名なElixir/Phoenixですが、実際にマイクロ秒とか見せられると、お前それ本当かよって突っ込みを入れたくなりますよね。とは言え、オッパイとアクセス速度は小さいに越したことありません。ロリコンも大満足です。今後のハッテンに期待でしょう。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした