Phoenix Framework 설치

3025 단어 ElixirPhoenix
Elixir의 대표적인 웹 프레임워크인 Phoenix Framework를 설치한다.

Phoenix Framework 설치


$ mix local.hex
$ mix archive.install https://github.com/phoenixframework/phoenix/releases/download/v0.13.1/phoenix_new-0.13.1.ez

프로젝트 만들기


$ mix phoenix.new hello_phoenix
* creating hello_phoenix/config/config.exs
... いろいろ表示 ...
* creating hello_phoenix/priv/static/images/phoenix.png

Fetch and install dependencies? [Yn] Y

Phoenix uses an optional assets build tool called brunch.io
that requires node.js and npm. Installation instructions for
node.js, which includes npm, can be found at http://nodejs.org.

After npm is installed, install your brunch dependencies by
running inside your app:

    $ npm install

If you don't want brunch.io, you can re-run this generator
with the --no-brunch option.


We are all set! Run your Phoenix application:

    $ cd hello_phoenix
    $ mix deps.get
    $ mix phoenix.server

You can also run it inside IEx (Interactive Elixir) as:

    $ iex -S mix phoenix.server


서버 시작


$ cd hello_phoenix
$ mix phoenix.server
==> fs (compile)
Compiled src/sys/inotifywait.erl
Compiled src/sys/fsevents.erl
Compiled src/sys/inotifywait_win32.erl

... いろいろ表示 ...

Compiled web/views/layout_view.ex
Generated hello_phoenix app
[info] Running HelloPhoenix.Endpoint with Cowboy on port 4000 (http)

module.js:340
    throw err;
          ^
Error: Cannot find module 'hello_phoenix/node_modules/brunch/bin/brunch'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.runMain (module.js:492:10)
    at process.startup.processNextTick.process._tickCallback (node.js:244:9)


brunch.io가 없으면 시작시 오류가 발생합니다.

브라우저로 액세스하면, 표시가 이상하게 되어 버리고 있다.

이번에는 phoenix framework를 움직이고 싶을 뿐이므로,
프로젝트를 만들 때 아래와 같이 표시된 대로 --no-braunch를 붙여서 다시 프로젝트를 만든다.
If you don't want brunch.io, you can re-run this generator
with the --no-brunch option.

다시 프로젝트 만들기


$ cd ..
$ rm -r hello_phoenix/
$ mix phoenix.new hello_phoenix --no-brunch

다시 서버 시작


$ cd hello_phoenix/
$ mix phoenix.server
==> fs (compile)
Compiled src/sys/inotifywait_win32.erl
... いろいろ ...
Compiled lib/hello_phoenix/endpoint.ex
Generated hello_phoenix app
[info] Running HelloPhoenix.Endpoint with Cowboy on port 4000 (http)

localhost:4000 방문



터미널에


[info] GET /
[info] Processing by HelloPhoenix.PageController.index/2
  Parameters: %{"format" => "html"}
  Pipelines: [:browser]
[info] Sent 200 in 7ms


브라우저 표시





이번은 제대로 표시된다.

좋은 웹페이지 즐겨찾기