Hello There!!, In the previous blog we lean how to deploy a rails application with passenger and nginx. Today we are going to learn how to deploy a rails application with passenger and nginx with SSL. Here is an example of that
Remove previously installed nginx
if you have already installed nginx then first remove the existing nginx before we start. For remove nginx run the command.
Remove old unicorn
If your site was running on unicorn then first uninstall unicorn and remove all unicorn config. Do the following steps.
sudo rm /etc/init.d/YOUR_APP_UNICORN_CONFIG_FILE_NAME
sudo update-rc.d -f YOUR_APP_UNICORN_CONFIG_FILE_NAME remove
Install nginx with passenger
First find the release of your ubuntu machine by running lsb_release -a
and copy the code name for further use. Now run the following commands to install nginx with passenger:
Enable the nginx passenger module
Edit /etc/nginx/nginx.conf
and uncomment passenger_root
and passenger_ruby
. For example, you may see this:
Remove the ‘#’ characters.
Check the installation
After installation you can validate the installation by running the following command: sudo passenger-config validate-install
Create a nginx config for your application
- Remove the existing file
/etc/nginx/site-enabled/default
. - Create new config file for your application and write the following lines inside that file:
Restart nginx service
After setting all the configs you need to restart the nginx service by running sudo service nginx restart
.
Restart passenger
If you want to restart passenger then you need to touch a file tmp/restart.txt. touch YOUR_APP_DIRECTORY/tmp/restart.txt
Show maintenance page during maintenance
You just need to do the steps:
touch YOUR_APP_DIRECTORY/tmp/maintenance.txt
after finish the maintenance just remove this file.rm YOUR_APP_DIRECTORY/tmp/maintenance.txt
and your application is live again.
Thanks for the reading !!!!!!