Elixir Phoenix 1.4 Deployments with Distillery and Edeliver on Ubuntu

I was having issues understanding how to deploy Phoenix applications, and decided to write an article on how I was eventually able to get it working with Distillery and Edeliver.

Hopefully this helps somebody. Let me know if you have any issues, or suggestions on how to improve the article.



Thank you very much for writing this - it’s almost exactly what I’m planning to do once I get my app to a state where it’s worth deploying. When that happens (which may still be a few weeks away), I’ll give this a go and let you know how I get on.

1 Like

@rasputin303 Excellent, Let me know how it goes!

looks great from a quick scroll through… good job :clap:


  • I would strongly suggest using a package manager like asdf (or other) to install elixir and even node (to be able to maintain dev/staging/prod parity by installing very specific versions - and also to have elixir compiled against the used otp version)
  • Making nginx optional - eg showing how to run phoenix directly on port 80, would be a nice addition. + ssl maybe?

also check out @ziazek 's A Beginner's Guide To Deployment with Edeliver and Distillery - that has articles on automated DB backup - and ssl setup… (maybe check if @ziazek has any good steps to perform that you might have missed…)


Thanks @outlog! Very helpful feedback.

That’s a good point about the version manager. I was curious if something similar to Ruby’s rbenv existed.

The main reason I used Nginx was so you could add another application to the same server more easily.

Also, I later adding SSL with letsencrypt via Nginx and it was pretty straightforward, so I’ll be updating the article with this new step soon.

I’ll check out the other article as well, thanks again.

1 Like

To clarify further, `asdf can manage more than Erlang and Elixir versions.

Thanks for the article. In production you should run an app as a Systemd service.

Thanks @ibarch, I just found a page in their Edeliver’s wiki for systemd. Gonna add this to the article too.

Thanks for the info in the article @tmartin314! Its the best comprehensive guide that is up to date I’ve been able to find for deploying apps w/o docker to your VPS of choice. Systemd and SSL are important final steps but this gets you 95% of the way there.

1 Like

Isn’t all that possible with HAProxy ? It would be great to see finally a Phoenix deployment guide that uses HAProxy instead of Nginx.

Anyway thank you for sharing this. ^^

1 Like


For Step 4:

  1. The dependencies installation didn’t work unless you add the bionic universe repo iirc. I tinker around with many solution but I believe the one that work was adding the universe repo. Solution.
  2. For $5 droplet it only works if you create a swapspace (I set it via 4GB) and wait a bit for asdf to install and build erlang felt like 30 min. Source for problem. The solution.

For step Step 7:

  1. I think there’s a typo it should be sudo apt-get update
  2. I think you should cd ~ or make sure in home dir after su postgres otherwise it complains about making a directory in root
  3. typo pgsql should be psql
  4. Maybe add \q to quit psql but I’m being picky now.

I’m only on step 9… I’ll update this post later on if you like to hear more. Thank you for making this post.

A out of there suggestion would be using terraform or ansible for these configurations.

But I haven’t used or done dev ops in forever. Terraform is something I’ve been meaning to try out when I have time, I think it does what ansible does…


You can use them both, they complement each other.

Terraform config files declaratively describe the servers/VMs to be created and is meant to be provider agnostic so you can create a mix of cloud servers at AWS, Azure, Digital Ocean, etc etc and local (VMWare), etc. When run it compares the current state of your infrastructure with how you declared you want it to change and it provisions/changes any new resources for you. It’s like CloudFormation but instead of just working with AWS it works with dozens of other providers. IMO it’s very good stuff.

After the infrastructure is created then Ansible (or if you prefer Chef, Puppet, Saltstack, etc) installs, configures, and manages software (such as Nginx, PostgreSQL, Distillery releases, etc) on the newly created servers.

1 Like

@mythicalprogrammer Thanks for the details! I’m glad you took the time to outline some issues you encountered.

I’ll update the post with some of these finer details, and let me know if you have any more issues.

About terraform et al, This was just meant to be a gentle intro to deployments and I think adding in complex tooling would make it less approachable to some people.

Thanks again!

1 Like

I’ll update the post with some of these finer details, and let me know if you have any more issues.

I just finished deploying with your tutorial (minus setting up nginx section).

I’ve encountered 3 4 issues.

  1. Another problem was I had to disable passphrase on my ssh key otherwise edelivery would throw error. I have no solution for this other than removing passphrase from my existing ssh key.

  2. Edeliver/Distillery fails with “bash: line 10: mix: command not found” error? With asdf installed I was getting the mix command not found error. I ended up using the third solution. The second solution give a good reason why I was encountering the problem.

  3. Another issue was ** (Mix) The task "release" could not be found. The reason turns out to be I didn’t commit to git master branch and I was in a branch. Solution and detail of problem.

  4. After deploying. I couldn’t figure out why I was getting server error. I figure out after a few minute that my db wasn’t built. After tinkering with config I realize I had to do. mix edeliver migrate production I skimed through the Admin commands section thinking that it wasn’t necessary.

Thanks again and have a great day.