Skip to content

Instantly share code, notes, and snippets.

@faithandbrave
Last active June 1, 2017 04:34
Show Gist options
  • Select an option

  • Save faithandbrave/3a3f80d0bb933322791b1ed928de5b0e to your computer and use it in GitHub Desktop.

Select an option

Save faithandbrave/3a3f80d0bb933322791b1ed928de5b0e to your computer and use it in GitHub Desktop.

ElixirとPhoenixのHello, world

MacのHome Brew環境でElixirの作業環境を作ったのでメモ。

Elixirのインストール

http://elixir-lang.org/install.html

$ brew install elixir

Hello, world

main.exs

IO.puts "Hello, world"
$ elixir main.exs
$ Hello, world

Phoenixのインストール

http://www.phoenixframework.org/docs/installation

$ mix archive.install https://github.com/phoenixframework/archives/raw/master/phoenix_new.ez

MySQLをインストール

MySQLの起動を忘れずに。

$ brew install mysql
$ mysql.server start

Nodeとnpmをインストール

$ brew install node
$ npm install

Phoenixのプロジェクト作成

デフォルトのデータベースがPostgreSQLなので、MySQL (MariaDB)に変更。

$ mix phoenix.new hello_phoenix --database mysql
$ cd hello_phoenix
$ mix ecto.create

Phoenixサーバーを起動

$ mix phoenix.server

これで、4000番ポートでサーバーが起動する。 http://localhost:4000/ で確認できる。

サーバーを停止するときは、Ctrl+C => a (Abort)

サーバーをデーモンで起動するには、以下のようにする:

$ elixir --detached -S mix phoenix.server
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment