Phoenix 입문 #01
링크
정책
환경
설치
여기서는 다음을 설치한다.
Vagrant
mkdir phoenix_start && cd phoenix_start
vagrant init ubuntu/trusty64
vgrant up
루비
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.provision "shell", path: 'provision.sh'
end
Erlang, Elixir, Node.js
Erlang, Elixir는 공식 INSTALL 거리에 설치합니다.
Node도 apt-get으로 텍토에.
provision.sh
# install erlang, elixir
wget http://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb && sudo dpkg -i erlang-solutions_1.0_all.deb
apt-get update
apt-get install -y elixir
# install node, npm
add-apt-repository ppa:chris-lea/node.js
apt-get update
apt-get install -y nodejs npm
provision하여 각각의 버전을 확인한다.
$ vagrant provision
...
$ vagrant ssh
...
$ erl -version
Erlang (ASYNC_THREADS) (BEAM) emulator version 6.4.1
$ elixir -v
Elixir 1.0.4
$ node -v
v0.10.37
$ npm -v
1.4.28
Phoenix
Elixir에는
mix
라는 빌드용 명령인지가 있는 것 같다. (Ruby에서 말하는 gem과 rake 같은 것?)우선은
mix
로 hex
라고 하는 패키지 매니저를 넣는다.hex를 설치하거나 듣기 때문에
y<Enter>
에 설치.$ mix local.hex
Are you sure you want to install archive https://s3.amazonaws.com/s3.hex.pm/installs/1.0.0/hex.ez? [Yn] y
2015-06-07 18:21:34 URL:https://s3.amazonaws.com/s3.hex.pm/installs/1.0.0/hex.ez [262010/262010] -> "/home/vagrant/.mix/archives/hex.ez" [1]
* creating .mix/archives/hex.ez
준비가 되었으므로 phoenix를 설치한다.
$ mix archive.install https://github.com/phoenixframework/phoenix/releases/download/v0.13.1/phoenix_new-0.13.1.ez
Are you sure you want to install archive https://github.com/phoenixframework/phoenix/releases/download/v0.13.1/phoenix_new-0.13.1.ez? [Yn] y
* creating .mix/archives/phoenix_new-0.13.1.ez
설치가 끝나면
mix
에 새로운 부속 명령이 추가되었습니다.$ mix help | grep phoenix
mix phoenix.new # Create a new Phoenix v0.13.1 application
Phoenix 앱 생성
즉시 추가된 명령으로 생성.
디폴트의 DB는 PostgreSQL로,
--database mysql
를 붙이면 MySQL을 사용할 수 있는 것 같다.$ mix phoenix.new phoenix_blog --database mysql
* creating phoenix_blog/config/config.exs
...
* creating phoenix_blog/priv/static/images/phoenix.png
Fetch and install dependencies? [Yn] y
* running npm install
* running mix deps.get
We are all set! Run your Phoenix application:
$ cd phoenix_blog
$ mix phoenix.server
You can also run it inside IEx (Interactive Elixir) as:
$ iex -S mix phoenix.server
덧붙여서
-
는 app명을 지정하지 않으면 용서되지 않는 것 같다.$ mix phoenix.new phoenix-blog
** (Mix) Application name must start with a letter and have only lowercase letters, numbers and underscore, got: "phoenix-blog". The application name is inferred from the path, if you'd like to explicitly name the application then use the `--app APP` option.
생성이 끝났으므로 실행해 보자.
$ cd phoenix_blog
$ mix phoenix.server
Could not find rebar, which is needed to build dependency :poolboy
I can install a local copy which is just used by mix
Shall I install rebar? [Yn] y
* creating /home/vagrant/.mix/rebar
==> poolboy (compile)
Compiled src/poolboy_worker.erl
...
Compiled web/views/layout_view.ex
Generated phoenix_blog app
[info] Running phoenix_blog.Endpoint with Cowboy on port 4000 (http)
07 Jun 18:36:33 - info: compiled 3 files into 2 files in 1680ms
최초의 기동에는 라이브러리 등의 빌드가 실행되는 것처럼 조금 시간이 걸린다.
빌드가 끝났으므로 http://192.168.33.10:4000/ (Vagrantfile로 지정한 IP)에 액세스 해 본다.
이번은 여기까지.
다음 번은 CRUD를 만드는 파트.
2부로
Reference
이 문제에 관하여(Phoenix 입문 #01), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/iyuuya/items/74e6ec2b840f938c70ce텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)