phoenix-framework Getting started with phoenix-framework Installation


Example

Phoenix framework is written in Elixir, and Elixir itself is based on Erlang language and leverages the Erlang VM, known for running low-latency, distributed and fault-tolerant systems. Both languages are required for using phoenix framework. Following following step to install phoenix framework:

1. Install Elixir on your machine. See Elixir Installation and how to install Elixir guide.

2. Install Hex package manager. Hex is a necessary tool to get a Phoenix app running and to install any extra dependencies we might need along the way. From your terminal or command control window, type:

$ mix local.hex

This command will install or update Hex, if you already have.

3. Install Erlang on your machine. Without Erlang, Elixir code will not compile because Elixir use Erlang's VM for code compilation. When you will install Elixir, you have probably installed Erlang too, but if it is not the case then follow these instruction on Elixir guide to install Erlang. However, If you are have Debian-based system, you may need to explicitly install Erlang.

$ wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb && sudo dpkg -i erlang-solutions_1.0_all.deb
$ sudo apt-get update
$ sudo apt-get install esl-erlang

4. Install phoenix framework on your machine. Once we have Elixir and Erlang, we are ready to install the Phoenix Mix archive. A Mix archive is a Zip file which contains an application as well as its compiled BEAM files. It is tied to a specific version of the application. The archive is what we will use to generate a new, base Phoenix application which we can build from. Here's the command to install the Phoenix archive:

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

Your can download packages manually, if above command doesn't work properly for you. Download packages to your file system Phoenix archives and run following command

mix archive.install /path/to/local/phoenix_new.ez

5 Plug, Cowboy, and Ecto are components of Phoenix framework, they will be installed automatically by mix, if you let mix install its dependencies, when you will first create Phoenix projects. Furthermore, if you don't allow mix to download these components then mix will tell you how how to do so later.

6. Install Node.js (not less then v5.0.0) on your machine. This is an optional dependency. Node.js is required to install brunch.io dependencies. Brunch.io is used by Phoenix for compiling static assets (javascript, css, etc), by default.

We can get node.js from the download page. When selecting a package to download, it's important to note that Phoenix requires version 5.0.0 or greater.

Mac OS X users can also install node.js via homebrew.

Note: io.js, which is an npm compatible platform originally based on Node.js, is not known to work with Phoenix.

Debian/Ubuntu users might see an error that looks like this:

sh: 1: node: not found
npm WARN This failure might be due to the use of legacy binary "node"

This is due to Debian having conflicting binaries for node: see discussion on following SO question

Cannot install packages using node package manager in Ubuntu

There are two options to fix this problem, either:

install nodejs-legacy:

$ apt-get install nodejs-legacy

or create a symlink

$ ln -s /usr/bin/nodejs /usr/bin/node

7 Install Database (PostgreSQL) on your machine. Phoenix configures applications to use it by default, but we can switch to MySQL by passing the --database mysql flag when creating a new application. The PostgreSQL wiki has installation guides for a number of different systems.

Postgrex is a direct Phoenix dependency and it will be used to create models. Postgrex will be automatically installed along with the rest of dependencies when you will create and start Phoenix project.

8 inotify-tools (for linux users) This is a Linux-only filesystem watcher that Phoenix uses for live code reloading. (Mac OS X or Windows users can safely ignore it.)

Linux users need to install this dependency. Please consult the inotify-tools wiki for distribution-specific installation instructions.