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.
- Server (VM or physical) accessible and ssh setup for deployment
- You need app which ready to go server ( Normal app ,Docker, Container )
- Web app server just like (apache, nginx) also you need your passenger mod for assist
- Ruby, rail, gems installed
- 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
- Enable passenger Mod using below command
$ sudo a2enmod passenger
- 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.