[How to] How to create a simple ROR application on a domain

Refers to:

  • Plesk 9.x and below for Linux

Created:

2016-11-16 13:11:23 UTC

Modified:

2016-12-21 20:09:02 UTC

0

Was this article helpful?


Have more questions?

Submit a request

[How to] How to create a simple ROR application on a domain

For other versions of Parallels Plesk please see the following articles: 10.4, 11.0 , 11.5 and 12 .

Symptoms

How to create a simple Ruby on Rails (ROR) application on a domain?

Resolution

  1. Enable ROR support in Parallels Plesk Panel. You may do this via Autoinstaller in the Control Panel. Log in to Parallels Plesk Panel as admin and navigate to this page: Home -> Updates -> Parallels Plesk Panel 9. Enable the Ruby on Rails support option and click the Install button to start installation of ROR support.

  2. Create a test domain, DOMAIN.TLD.

  3. In the hosting configuration, enable SSH access, CGI, and FastCGI (Domains -> DOMAIN.TLD -> Web Hosting Settings):

    Shell access to server with FTP user's credentials [/bin/shell]
    CGI support [x]
    FastCGI support (required for Ruby on Rails) [x]

(where /bin/shell is the shell available for the Plesk server). The list of system shells is stored in the /etc/shells file and can be obtained by the system administrator:

    ~# cat /etc/shells
/bin/sh
/bin/bash
/sbin/nologin
/bin/tcsh
/bin/csh
/bin/rbash
~#

4\. Log in to the domain via SSH with the login and password of the domain FTP user:

    ~# ssh FTP.USER@DOMAIN.TLD 
-sh-3.2$ ls -l
total 48
drwxr-x--- 5 FTP.USER psaserv 4096 Apr  3 11:27 anon_ftp
drwxr-xr-x 2 root     psaserv 4096 Apr  3 11:27 bin
drwxr-x--- 3 FTP.USER psaserv 4096 Apr  3 11:27 cgi-bin
drwxr-x--- 2 root     psaserv 4096 Apr 10 09:17 conf
drwxr-xr-x 2 root     psaserv 4096 Apr  3 11:27 error_docs
drwxr-x--- 7 FTP.USER psaserv 4096 Apr  3 11:27 httpdocs
drwxr-x--- 7 FTP.USER psaserv 4096 Apr  3 11:27 httpsdocs
drwxr-x--- 2 root     psaserv 4096 Apr  3 11:27 pd
drwx------ 2 FTP.USER root    4096 Apr  3 11:27 private
dr-xr-x--- 7 root     psaserv 4096 Apr  3 11:27 statistics
drwxr-xr-x 2 root     psaserv 4096 Apr  3 11:27 subdomains
drwxr-xr-x 2 root     psaserv 4096 Apr  3 11:27 web_users
-sh-3.2$
  1. Change to the httpdocs directory:

    -sh-3.2$ cd httpdocs
  2. Create a test application, ruby\_test\_application, in the current directory:

    -sh-3.2$ 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.

  1. Change to the ruby\_test\_application directory:

    -sh-3.2$ cd ruby_test_application
  2. Execute the following command to create a new controller with the name Hello:

    -sh-3.2$ ruby script/generate controller Hello index
          exists  app/controllers/
          exists  app/helpers/
          create  app/views/hello
          exists  test/functional/
          create  app/controllers/hello_controller.rb
          create  test/functional/hello_controller_test.rb
          create  app/helpers/hello_helper.rb
          create  app/views/hello/index.rhtml
    -sh-3.2$

You may use another name for the test controller. (Replace "Hello" as you like.)

  1. Open the ruby\\_test\\_application/app/controllers/hello\\_controller.rb file in a file editor and change its content. Currently, you are in the ruby\\_test\\_application directory, so you should use the following command to open the file:
    -sh-3.2$ pwd
    /var/www/vhosts/DOMAIN.TLD/httpdocs/ruby_test_application
    -sh-3.2$ vim app/controllers/hello_controller.rb

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
  1. Open the ruby\\_test\\_application/app/views/hello/index.html.erb file in the file editor:
    `-sh-3.2$ pwd
    /var/www/vhosts/DOMAIN.TLD/httpdocs/ruby_test_application
    -sh-3.2$ vim app/views/hello/index.html.erb`

And change content from

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

to

    ---
<h1><%= @message %></h1>
---
  1. Put the .htaccess file with the following content into the application’s root (/var/www/vhosts/DOMAIN.TLD/httpdocs/ruby\_test\_application):

    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]
  2. 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'
  3. Open the application in a web browser to see if it works:

    http://DOMAIN.TLD/ruby\\_test\\_application/Hello

There should be a record named Hello World.

Additional information

Documentation about installation of Ruby web applications on a Plesk domain is available in Parallels Plesk Panel 9 Administrator's Guide .

Have more questions? Submit a request
Please sign in to leave a comment.