Deploy Elixir project to AWS EC2 instance

I am new to elixir. I have created one instance in AWS and i wanted to launch my elixir project in that instance. Inside an instance i have installed erlang 19.0 and elixir 1.4.2 version and also i have pushed my elixir code inside aws server in /var/www/projects/ directory. After this i have changed Document root also to my project directory /var/www/projects/my-project-elixir/web . But i am not able to host it properly. Can anyone guide me properly to host my elixir project in aws server??

Basic steps are:

  • compile your release locally/on staging (basically a system that has similar operating system and same processor architecture as your host)
  • push it to your host
  • start it
  • optional: use nginx or apache in reverse proxy mode to forward requests on port 80 to the port your app is listening on

There are some tools available that do all of these at once, but still assume an indepth knowledge of what you have to do when and where if you were doing it manually.

I found this tutorial/walkthrough a good reference on how to do it. Just substitute the DigitalOcean references to your EC2 and you should be fine to go. Read through the comments if you run into any problem.

1 Like

Seeing /var/www and “document root” I’m guessing you’re coming from PHP deployments?

Elixir (just like most other languages than PHP) have different deployment methods, in which the deployment artifact, be it source code or compiled code, is run as a process, as opposed to PHP’s just-upload-the-code-to-server approach. Webservers such as Apache or Nginx are not necessary (e.g. you can tell your app to listen in port 80/443), but most of the time useful as a reverse proxy (what is a reverse proxy? It doesn’t matter for now).

How did you run the code locally? Try to replicate it on your server. Did you get the app to run?

Can i have link of any reference regarding deployment??

All in releases: https://hexdocs.pm/distillery/getting-started.html

Hi,

I have a same problem. Have you deployed the Elixir code on AWS EC2 instance? If so, please help me.

Jian

yes, What problem you are facing??

As @OvermindDL1 said you can start with distillery and upload the source code directly to EC@ instance after you done that you can start using edeliver. If you are using the edeliver the main thing you have to do is to add ip of the EC2 instance.

1 Like