You have built an awesome application using Ruby on Rails, and have no idea how to make it available to the world wide web. By the end of this tutorial, you will have your application up and running on Apache. We will be using passenger with Apache in this post. So, let's get started.
$ bundle install to install all the gems specified in the Gemfile.
Assuming you are in the root directory of your project, open your
config/database.yml and edit the username/password in the production section of the file.
Once done run the following commands in sequence:
$ bundle exec rake db:create RAILS_ENV=production $ bundle exec rake db:migrate RAILS_ENV=production
Navigate to your
config/environments/production.rb and set the following:
config.serve_static_assets = true config.assets.compile = true
$ bundle exec rake assets:precompile
This is the gem that does all the magic of deploying our rails application.
$ gem install passenger
Run the following command:
If there are any dependencies that Apache needs, it prompts and you can install it via your package manager.(then again run: passenger-install-apache2-module).
Once that is done, the installation will ask you to copy paste some lines into the apache configuration file.
In your sites-available directory of Apache, create a file called,
my_app and paste the following lines:
<VirtualHost *:80> ServerName YOURSERVERNAME DocumentRoot /PROJECT_PATH/public <Directory /PROJECT_PATH/public> Options -MultiViews AllowOverride All Order deny,allow Allow from all </Directory> </VirtualHost>
$ sudo a2ensite my_app
Restart Apache, navigate to your server name and enjoy :)