Web Hosting Plus Logo

Web Hosting How-To Articles, Help and Information at Web Hosting Plus

How do I set up Ruby on Rails?

Back to Help Main Page

Ruby on Rails is a database-driven website framework designed to be easy for programmers to maintain.

To set it up, you will need a hosting package with:-
  • SSH access
  • 3 MySQL databases (for a standard test, production, live configuration)
The ideal way to install Rails is using our "setup_rails.sh" script, which will correctly configure Rails for MySQL and our web servers.

Once you have logged in to SSH, to install Rails at http://www.yoursite.com/somedirectory you'd do:

[yoursite.com@web224 ~]$ /usr/local/bin/setup_rails.sh somedirectory
[yoursite.com@web224 ~]$ ln -sf `pwd`/somedirectory/public public_html/somedirectory
[yoursite.com@web224 ~]$

You now need to configure Rails to access your MySQL databases. For this you will need to set up 3 databases (by default) using the Web Hosting Plus Control Panel. Note down the names of these, for example you could choose web224-rubyprod, web224-rubytest, web224-rubylive.

Edit the file somedirectory/config/database.yml (NOTE: not database.yaml, as the script will erroneously instruct) and update the database, username and password settings appropriately.

You can now visit http://www.yoursite.com/somedirectory to see the welcome page and confirm the installation has succeeded.

If you want to go on to create a sample page, try:

[yoursite.com@web224 ~]$ cd somedirectory
[yoursite.com@web224 somedirectory]$ script/generate controller welcome
            exists app/controllers/
            exists app/helpers/
            create app/views/welcome
            exists test/functional/
            create app/controllers/welcome_controller.rb
            create test/functional/welcome_controller_test.rb
            create app/helpers/welcome_helper.rb
[yoursite.com@web224 somedirectory]$ echo '<b>Hello</b>, World! 1 + 2 = <%= 1+2 %>' > app/views/welcome/index.rhtml
[yoursite.com@web224 somedirectory]$

You would then be able to view this at http://www.yoursite.com/somedirectory/welcome . For more information, please see the Ruby on Rails web site.

If you want to have your entire site run through Rails (and you're certain), then rename your public_html directory, and follow the same procedure above except that instead of "ln -sf `pwd`/somedirectory/public public_html/somedirectory" you should write "ln -sf `pwd`/somedirectory/public public_html".

This is in reply to:

How do I set up Ruby on Rails?

Web Hosting Plus Help Main Page