Hybrid Robotics

Robotics, Gadgets, Circuits, Toys, Radio, and other Tech

Getting Up and Running with Elixir and Phoenix

April 22, 2017

There is a little work to be done to get up and running with the latest versions of Elixir and Phoenix on a Raspberry Pi 2 or 3, but it is not too bad if done right. I had to do a bit of information collecting from a few different sources to make it happen, and have collected the procedure I used here. This procedure assumes you are running either Raspian or Ubuntu 16.04. In my case, I am running Ubuntu MATE 16.04, so that is what this post will assume.

You can download Ubuntu MATE 16.04 for the Raspberry Pi 2 and 3 here

Add the repository for elixir and erlang.

sudo echo "deb http://packages.erlang-solutions.com/debian jessie contrib" | sudo tee /etc/apt/sources.list.d/erlang-solutions.list

sudo wget http://packages.erlang-solutions.com/debian/erlang_solutions.asc

sudoapt-key add erlang_solutions.asc`

Update the repository information.

sudo apt-get update

Install Elixir, inotify, PostGreSQL, and some other prerequisites.

sudo apt-get install elixir erlang-dev erlang-parsetools inotify-tools postgresql

Now, you have the latest and greatest versions of Elixir and Erlang installed! You will also need a few other things to make this all work.

inotify enables Elixir’s live load feature, so any changes you make to Phoenix code for the web will take effect immediately.

erlang-dev and erlang-parsetools are required.

PostGreSQL is the database Phoenix uses by default, and it is better than MySQL.

If you have not set a password for root, you will need to do that now.

sudo passwd root
<enter a good password>

su -
<enter your root password>

su – postgres
psql

ALTER USER postgres with encrypted password 'postgres';

\q
exit

This will set a password for the ‘postgres’ use in the PostGreSQL database software. This is the default password used my the Phoenix database package, ecto. If you want to set a different password for the database ‘postgres’ account, change the password you use in the ALTER USER command above and in your <project name>/config/dev.exs file.

Now, it is time to install Phoenix! Login to the account you will be running Phoenix from – this should NOT be the root (superuser) account!

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

Now, you have everything you need to get up and running with Elixir and Phoenix in the least amount of time!

You can create a new project my doing mix phoenix.new <project name>

By Dale