https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-16-04
https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-16-04
https://www.digitalocean.com/community/tutorials/how-to-install-ruby-on-rails-with-rbenv-on-ubuntu-16-04
https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-ubuntu-16-04
https://www.phusionpassenger.com/library/walkthroughs/deploy/ruby/digital_ocean/nginx/oss/xenial/install_passenger.html
Remove default config at /etc/nginx/sites-available/default
or comment out the default_server lines.
Create new config file for site:
# /etc/nginx/sites-available/myapp.conf
server {
listen 80 default_server;
server_name myapp.com;
root /var/www/myapp/current/public;
passenger_enabled on;
passenger_app_env production;
passenger_ruby /home/deploy/.rbenv/versions/2.5.1/bin/ruby;
passenger_env_var LANG en_US.UTF-8;
passenger_env_var MYAPP_DATABASE_USERNAME myapp;
passenger_env_var MYAPP_DATABASE_PASSWORD super-strong-password;
}
Symlink config to sites-enabled
Symlink to /etc/nginx/sites-enabled/myapp.conf
to enable the site
ln -s /etc/nginx/sites-available/myapp.conf /etc/nginx/sites-enabled/myapp.conf
Update app directory permission
Set user deploy
as owner of /var/www/myapp
so Capistrano can mkdir
to it
https://stackoverflow.com/questions/24470520/capistrano-mkdir-permission-denied
sudo chown deploy:deploy /var/www/myapp
Setup Let's Encrypt HTTPS
https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-16-04
Additional useful information
Nginx folder structure
https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-16-04