$ sudo apt-get install nginx
$ sudo apt-get install -y dirmngr gnupg apt-transport-https ca-certificates curl
$ curl https://oss-binaries.phusionpassenger.com/auto-software-signing-gpg-key.txt | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/phusion.gpg >/dev/null
$ sudo sh -c 'echo deb https://oss-binaries.phusionpassenger.com/apt/passenger jammy main > /etc/apt/sources.list.d/passenger.list'
$ sudo apt-get update
$ sudo apt-get install -y libnginx-mod-http-passenger
$ sudo vi /etc/nginx/conf.d/mod-http-passenger.conf
passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;
passenger_ruby /home/deploy/.rbenv/shims/ruby;
$ sudo vi /etc/nginx/nginx.conf
$ sudo vi /etc/nginx/sites-available/myapp
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name my.ip.address;
root /home/deploy/myapp/current/public;
# Add index.php to the list if you are using PHP
passenger_enabled on;
passenger_ruby /home/deploy/.rbenv/shims/ruby;
passenger_app_env staging;
client_max_body_size 800M;
}
$ sudo ln -s /etc/nginx/sites-available/myapp /etc/nginx/sites-enabled/
$ sudo nginx -t
$ sudo service nginx start
$ sudo /usr/bin/passenger-config validate-install
$ sudo /usr/sbin/passenger-memory-stats
$ passenger-config restart-app
If you get an eeror that passenger is not serving any applications, go to the browser and paste the url again. Do not reload, it won't work. You have to enter the url afresh
For a rails deployment, it's better if all this information is in one place, rather than scattered in a bunch of gists. I'd recommend using an infrastructure automation tool such as ansible or chef.