Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save JudahSan/bc4cd4b924418f1af237bdec6c7cfe17 to your computer and use it in GitHub Desktop.
Save JudahSan/bc4cd4b924418f1af237bdec6c7cfe17 to your computer and use it in GitHub Desktop.

Install nginx

$ 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

Add APT repository

$ 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

Install Passenger + Nginx module

$ sudo apt-get install -y libnginx-mod-http-passenger

Edit Passenger Conf

$ 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;

Set user to deploy in nginx.conf

$ sudo vi /etc/nginx/nginx.conf

Create sites-available nginx file for your domain

$ 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;
}

Symlink sites-available with sites-enabled

$ sudo ln -s /etc/nginx/sites-available/myapp /etc/nginx/sites-enabled/

Check if nginx is correctly configured

$ sudo nginx -t

Start Nginx

$ sudo service nginx start

Validate Passenger install

$ sudo /usr/bin/passenger-config validate-install

Check whether passenger has started nginx core process

$ sudo /usr/sbin/passenger-memory-stats

Start passenger

$ 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment