You are here
Home > howto >

Deploy Rails App on AWS Server

This post is very quick guide about how to deploy ruby on rails application on AWS cloud running apache2 webserver. Deploying application means putting it on a Web server so that it can be used either through the Internet or an intranet. This Web server might be local UNIX system, while you develop and debug your application to check its working or a AWS cloud server.

System Pre-requisites

  1. Server (VM or physical) accessible and  ssh setup for deployment
  2. You need app which ready to go server ( Normal app ,Docker, Container )
  3. Web app server just like (apache, nginx) also you need your passenger mod for assist
  4. Ruby, rail, gems installed
  5. Last your required database which you want to use (MySQL, SQLite etc.)

Steps To Deploy Rails App on AWS Server

  •  Login to server where you want to deploy your app using SSH.
  • After login into server use “ ls “ command to check your app is present or not if no then Copy app to directory of server with read and write permission.
  • Database installation .(in our case we already configured database)
  • Run command “bundle install” this fetch all latest gems on server
  • Try to run app using puma or webrick using “rails s” command
  • Next step is installation of apache – if apache is not installed before
$ sudo apt update
$ sudo apt install apache2 libapache2-mod-passenger
  • Apache configuration and setting up virtual host, file located at /etc/apache2/sites-enabled/000-default.conf
$ sudo vim /etc/apache2/sites-enabled/000-default.conf
Apache configuration for ruby on rails application
  • Enable passenger Mod using below command
$ sudo a2enmod passenger
Passenger mod working with RoR application
  • Default site disable and enable new site. (If you have used virtual host in default then don’t disable it )
$ sudo a2dissite 000-default.conf
$ sudo a2ensite new_site.conf
  • Test the site from public IP / hostname or localhost

Troubleshooting Ruby App deployment errors

Apache not working properly due to syntax error in apache2.conf

Fix syntax errors and restart apache

Passenger Mod not working properly

uninstall passenger mod and re-install it and configure passenger.conf file

$ sudo apt purge libapache2-mod-passenger
$ sudo apt install libapache2-mod-passenger

Hope you have enjoyed reading this quick guide on How to Deploy Rails App on AWS Server running apache with passenger.

Leave a Reply

Top