Skip to content

Instantly share code, notes, and snippets.

@phollyer
Last active May 27, 2021 13:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phollyer/cb3428e6c23b11fadc5105cea1379a7c to your computer and use it in GitHub Desktop.
Save phollyer/cb3428e6c23b11fadc5105cea1379a7c to your computer and use it in GitHub Desktop.
Setup Ubuntu 18.04 server for Elixir Apps behind Nginx
# The process that follows enables an Elixir/Phoenix release to be built and deployed with edeliver.
# However, it results in a 502 Bad Gateway error when trying to access the app over HTTP.
# I have posted a question here: https://stackoverflow.com/questions/61808572/502-bad-gateway-elixir-phoenix but
# as of posting this Gist, I have been unable to resolve the issue.
# If anyone can help, please post in the comments here, or on the SO question. I'll keep this Gist up to date
# with SO and vice versa.
#
# Thank You to anyone that can help.
#
# Some of the steps might seem obvious, but I've included every step taken to help any noobs that come across this.
#
# Add & Create Sudo User: (https://linuxconfig.org/how-to-create-sudo-user-on-ubuntu-18-04-bionic-beaver-linux )
sudo adduser username
# Add the user to the sudo group
sudo usermod -aG sudo username
# SSH Keys: (https://linuxize.com/post/how-to-set-up-ssh-keys-on-ubuntu-1804/)
ssh-copy-id remote_username@server_ip_address
# Install Erlang & Elixir: (https://elixir-lang.org/install.html#unix-and-unix-like)
wget https://packages.erlang-solutions.com/erlang-solutions_2.0_all.deb && sudo dpkg -i erlang-solutions_2.0_all.deb
sudo apt-get update
sudo apt-get install esl-erlang
sudo apt-get install elixir
# Install Nginx: (https://phoenixnap.com/kb/install-nginx-on-ubuntu)
sudo apt update
sudo apt install nginx
sudo systemctl enable nginx
# Install MongoDB: (https://websiteforstudents.com/install-mongodb-on-ubuntu-18-04-lts-beta-server/)
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list
sudo apt update
sudo apt install -y mongodb-org
sudo systemctl enable mongod.service
# UFW: (https://linuxize.com/post/how-to-setup-a-firewall-with-ufw-on-ubuntu-18-04/)
sudo ufw allow ssh
sudo ufw enable
sudo ufw allow 'Nginx FULL'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment