In order to develop elixir applications, you will need to install elixir itself, erlang because elixir is made for the erlang virtual machine, nodejs for compiling assets in phoenix, and you'll most likely want a RDBMS (relational database management system) such as postgresql or MySQL. These can of course be installed by your distribution's package manager - in fact, there are official instructions for doing so for various distributions here.
You may, however, find yourself developing projects under different versions of elixir, erlang, and possibly even your RDBMS. For such situations, it's useful to use a version manager (those from a ruby background may be familiar with chruby, rbenv, or rvm). This software allows you to install multiple versions of your tools, and switch between them (mostly) automatically, using a file that specifies the version in each project.
The asdf version manager allows version management of multiple different tools using a plugin system. Let's install asdf, then use it to install elixir, erlang, nodejs, and postgresql.
The README on the asdf page has excellent instructions (in fact the below are practically copied from there with modifications for our specific use case); if your environment is different from the standard - for example if you're using a shell other than bash - I'd recommend referring to them.
Many plugins will need tools to compile them, and libraries to link to. These need to be installed using your distribution's package manager:
sudo apt-get install automake autoconf libreadline-dev libncurses-dev libssl-dev libyaml-dev libxslt-dev libffi-dev libtool unixodbc-dev
sudo yum install automake autoconf readline-devel ncurses-devel openssl-devel libyaml-devel libxslt-devel libffi-devel libtool unixODBC-devel
git clone https://github.com/asdf-vm/asdf.git ~/.asdf echo -e '\n. $HOME/.asdf/asdf.sh' >> ~/.bashrc echo -e '\n. $HOME/.asdf/completions/asdf.bash' >> ~/.bashrc source ~/.bashrc
If you have any trouble running these, start a new shell.
asdf plugin-add erlang https://github.com/asdf-vm/asdf-erlang.git asdf plugin-add elixir https://github.com/asdf-vm/asdf-elixir.git asdf plugin-add nodejs https://github.com/asdf-vm/asdf-nodejs.git bash ~/.asdf/plugins/nodejs/bin/import-release-team-keyring asdf plugin-add postgres https://github.com/smashedtoatoms/asdf-postgres.git
asdf install erlang 19.3 asdf install elixir 1.4.5 asdf install nodejs 8.2.1 asdf install postgres 9.6.3
asdf global erlang 19.3 asdf global elixir 1.4.5 asdf global nodejs 8.2.1 asdf global postgres 9.6.3
.tool-versionswhich asdf uses to choose which version to use when you switch into the project directory by replacing
globalin the above snippet with
Since we have just installed Elixir for the first time, we will need to install the Hex package manager as well. Hex is necessary to get a Phoenix app running (by installing dependencies) and to install any extra dependencies we might need along the way.
Now that we have Hex installed we can install Phoenix
mix archive.install hex phx_new 1.4.10
If you haven't coded before you will want to take a look at additional tools for some extra tools that will help you get started otherwise we're good to go! Let's go write some elixir!