Deploy Ruby on Rails project with Passanger and Ngnix I am assuming that you have installed ruby and rails at your server and have aRuby on railsproject to deploy with Passanger and Ngnix Step 1 -Firstof all we need to add aSudo Userto our system so user can have privilege to access the files. create a user if not exists, in this example I will explain to create a root user tecorb@tecorb-Lenovo-B40-80:~$ adduser root (this will ask few questions like your password etc.) Step 2 -Now we have to add this new user to the sudo group Syntex: tecorb@tecorb-Lenovo-B40-80:~$gpasswd -a root sudo Step 3 -Now we need to install Passenger and Nginx First of all we will install a PGP (Pretty Good Privacy) key: tecorb@tecorb-Lenovo-B40-80:~$sudo apt-key adv --keyserver keyserver.ubuntu.com --recvkeys 561F9B9CAC40B2F7 Now we have to create an APT (Advanced Packaging Tool) source file tecorb@tecorb-Lenovo-B40-80:~$sudo vim /etc/apt/sources.list.d/passenger.list And insert the following line in the file: deb https://oss-binaries.phusionpassenger.com/apt/passenger trusty main PressESCthen:wqand hitenter, Now our file has been saved throughvi editor TecOrb Technologies Now we need to change the owner and permissions for thispassenger.listfile: tecorb@tecorb-Lenovo-B40-80:~$sudo chown root: /etc/apt/sources.list.d/passenger.list tecorb@tecorb-Lenovo-B40-80:~$sudo chmod 600 /etc/apt/sources.list.d/passenger.
To use in Apache: PassengerRuby /usr/local/rvm/wrappers/ruby-1.8.7-p358/ruby To use in Nginx : passenger_ruby /usr/local/rvm/wrappers/ruby-1.8.7-p358/ruby To use with Standalone: /usr/local/rvm/wrappers/ruby-1.8.7-p358/ruby /opt/passenger/bin/passenger start
From here you will get path for your passenger_ruby (Nginx). This path will use at passenger_ruby in nginx.conf
Now finally we will save our file and exit by PressESCthen type:wqand hit enter.
Step 5-Now we have allmost done, we need to disable the default Nginx configuration at Nginx config file:
tecorb@tecorb-Lenovo-B40-80:~$sudo vim /etc/nginx/sites-available/default
In this file we enable listening on port 80, set our domain, enable Passenger, set the application environment here we have used development environment and set the root to the public directory of our ruby on rails project. If you don't want to add your domain to the application, you can skip the server_name line from this file, or if you want to use any IP address you can replace tecorbdomain.com www.tecorbdomain.comwith your ip address.
Now we will save this config file, PressESCthen type:wqand hit enter.
Step 7-Now finally we will create a symlink this file: