Knowledgebase: PHP/Ruby Hosting Plans
Ruby on Rails 3.2 support on CPanel servers
Posted by - NA - on 24 July 2013 05:59 AM

cPanel does not support Ruby 1.9 or Ruby on Rails 3.2, only Ruby 1.8 and Rails 2.3. It means that you cannot create and manage RoR 3.2 applications using the Ruby on Rails section in cPanel - everything will have to be done using the command line instead.

In order to add Rails 3.2 applications on your account, you need to login via SSH client and prepare the environment by issuing the following commands:

bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
rm -f .gemrc
source "$HOME/.rvm/scripts/rvm"
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"' >> ~/.bashrc
rvm install 1.9.3
rvm --default 1.9.3
gem install rails --version "=3.2.13"

These commands will install Ruby 1.9 and Rails 3.2.13 environment on your account. Now you can create your Rails 3.2 application:

rails new hello_world
cd hello_world
bundle install --path vendor
bundle package
echo 'vendor/ruby' >> .gitignore

At the final step, you should point your site, subdomain, or add-on domain web root to your application:

mv ~/public_html ~/public_html.bak
ln -s ~/hello_world/public ~/public_html

Done, your Rails 3.2 application is ready.

 

Useful tips


1. How to restart your Rails application without restarting Apache:

cd <your_app_folder>
touch tmp/restart.txt

Application will be restarted next time you open it in browser.

2. Using the production environment automatically

You will probably want to use the production environment instead of the development one. To make that the default for all commands, simply set the RAILS_ENV environment variable:

export RAILS_ENV=production

To set it automatically when you log in:

echo "export RAILS_ENV=production" >> ~/.bashrc


3. Precompiling the assets

Since this is a production site you will need to precompile the assets:

rake assets:precompile

(82 vote(s))
Helpful
Not helpful

Comments (0)