How to create a simple Ruby on Rails application on a domain on the Debian 7.2?

Refers to:

  • Plesk 11.5 for Linux
  • Plesk

Created:

2016-11-16 12:57:01 UTC

Modified:

2017-02-06 13:41:22 UTC

0

Was this article helpful?


Have more questions?

Submit a request

How to create a simple Ruby on Rails application on a domain on the Debian 7.2?

Symptoms

How-To install a Ruby on Rails application in Plesk 11.5 on Debian 7.

Resolution

NB: these steps should be performed only if you have Plesk 11.5 installed on Debian 7 OS. For earlier versions of Plesk, please use this article

  1. install Ruby on Rails through autoinstaller

    /usr/local/psa/admin/sbin/autoinstaller '--select-release-current' '--install-component' 'ruby'
  2. install libfcgi-dev, libsqlite3-dev packages

    apt-get install libfcgi-dev libsqlite3-dev
  3. install sqlite3 and fcgi gems:

    gem install sqlite3
    gem install fcgi
  4. create a test application:

    rails -D ruby_test_application

    NOTE: "-D" is necessary to add dispatchers (dispatch.fcgi) into the public folder. Dispatchers are necessary for the Ruby on Rails application to work in Plesk with FastCGI.

  5. create .htaccess in the application root directory with the following context:

    RewriteEngine On
    RewriteRule ^$ public/index.html [L]
    RewriteCond %{REQUEST_URI} !^/ruby_test_application/public
    RewriteRule ^(.*)$ public/\\$1 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ public/dispatch.fcgi/$1 [QSA,L]
  6. modify public/dispatch.fcgi file:

    #require File.dirname(__FILE__) + "/../config/environment"    <-- old
    require File.absolute_path(__FILE__) + '/../../config/environment' <-- new
  7. open the config/routes.rb file in the editor and change lines starting with ' map.connect ' by adding ' /ruby_test_application/ ' in front of string values, e.g.:

    map.connect '/ruby_test_application/:controller/:action/:id'
    map.connect '/ruby_test_application/:controller/:action/:id.:format'

In order to create test page:

  1. Execute the following command to create a new controller with the name Hello:

    ruby script/generate controller Hello index
  2. Open the ' ruby_test_application/app/controllers/hello_controller.rb ' file in a file editor and change its content: Find the following content:

    class HelloController < ApplicationController

    def index
    end
    end

    and replace it with the following:

    class HelloController < ApplicationController
    def index
    @message = "Hello World"
    end
    end
  3. Open the ' ruby_test_application/app/views/hello/index.html.erb ' file in the file editor:And change content from

    <h1>Hello#index</h1>
    <p>Find me in app/views/hello/index.rhtml</p>

    to

    <h1><%= @message %></h1>
Have more questions? Submit a request
Please sign in to leave a comment.