Deploy a new Rails application

There are different ways to deploy a Rails application.

Use Apache with Passenger

The most common way to deploy a Rails application is with Apache and Passenger. Follow the steps below:

  • Create a new file at /home/bitnami/httpd-vhosts.conf and fill it with the following content.

    <VirtualHost *:80>
        ServerName HOST_NAME
        DocumentRoot "/home/bitnami/APPNAME/public/"
        <Directory "/home/bitnami/APPNAME/public/">
            Options -MultiViews
            <IfVersion < 2.3 >
            Order allow,deny
            Allow from all
            <IfVersion >= 2.3>
            Require all granted
            RailsEnv development
            PassengerEnabled on
            PassengerAppRoot "/home/bitnami/APPNAME/"

    Remember to replace the HOST_NAME placeholder with the host name of your cloud server and the APPNAME placeholder with the correct directory for your Rails application.

  • Next, edit the /opt/bitnami/apache2/conf/bitnami/bitnami-apps-vhosts.conf file and add the following line to the end of the file:

    Include /home/bitnami/httpd-vhosts.conf
  • Restart the Apache server.

    $ sudo /opt/bitnami/ restart apache

After restarting Apache, the application should be accessible by browsing to http://SERVER-IP/.

NOTE: Remember that you might need to adjust the permissions of your application directory and sub-directories to make them accessible to the user that the Apache server runs as - for example, with the command sudo chown bitnami:daemon /home/bitnami/APPNAME.

Use NGINX with Passenger

Follow these steps:

  • To configure NGINX to run at port 80, stop the Apache service. To do this, run the command below:

    $ sudo /opt/bitnami/ stop apache
  • Once the Apache service has been stopped, modify the server configuration at /opt/bitnami/nginx/conf/nginx.conf to be similar to this.

    server {
        listen 80;
        root /opt/bitnami/APPNAME/public;
        passenger_enabled on;
        rails_env development;

    NOTE: The configuration above runs Passenger in development mode because, by default, Passenger starts in production mode which requires a secret to be configured. Using development mode bypasses this requirement and lets you test that everything is working correctly. When deploying to production, remember to change this value and provide a

  • Before restarting NGINX to apply this configuration, disable Apache as shown below:

    $ sudo /opt/bitnami/ stop apache
    $ sudo mv /opt/bitnami/apache2/scripts/ /opt/bitnami/apache2/scripts/
    $ sudo mv /opt/bitnami/config/monit/conf.d/apache.conf /opt/bitnami/config/monit/apache.conf.disabled
  • Restart the NGINX service to apply the new configuration:

    $ sudo /opt/bitnami/ restart nginx

With this, your Ruby on Rails application will run at the root of your domain through the default HTTP port (80). You should now be able to access your Ruby on Rails applications with NGINX and Passenger on http://SERVER-IP/.

Last modification April 8, 2020