Ruby on Rails: Applications | Bluehost Support
Support
  1. bluehost knowledge base

Ruby on Rails: Applications

Overview

The process is been broken down into 8 easy-to-follow steps.



Getting started

  • Firstly, this article is considered outside the Scope of Technical Support.
  • Secondly, before you can follow this article, you are going to need SSH access. If you don"t know how to get SSH access, please review SSH Access.

Installing Ruby on Rails and Passenger

This article assumes you are already logged in to the server through SSH as root.

  1. Installing the Basics - We will be using the installruby script, located in /scripts, to get started. While this script installs more than what is listed here, below is what is important enough to take note of.
    • Ruby 1.8,7
    • RubyGems 2.1.9, and 1.8.25
    • rails-2.3.18
    • rake-10.1.0
    • rack-1.1.6
    • mongrel-1.1.5
    # /scripts/installruby
  2. Installing Passenger - Now that Ruby is installed, we will use the following command:
    # gem install passenger mysql
  3. Installing curl-devel
    # yum install curl-devel

    When prompted "Is this ok [y/N]:" type the letter "y" and press Enter.
  4. Installing postgresql-devel
    # yum install postgresql-devel
    Again, when prompted with the message "Is this ok [y/N]:" type the letter "y" and press Enter.
  5. Installing ImageMagick
    # /scripts/installimagemagick
  6. Installing passenger modules, for apache
    # passenger-install-apache2-module
    Confirm by pressing the Enter button.
    The system will check to see what you are missing. Press the Enter.
    1. When prompted "Are you sure you want to install against Apache 2.2.24 (/usr/bin/apxs)? [y/n]:" type the letter "y" and push enter. This will return "The Apache 2 module was successfully installed."
    2. Press the Enter.
    3. Add these lines to this file.
      /usr/local/apache/conf/includes/pre_main_2.conf
      LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-4.0.21/buildout/apache2/mod_passenger.so
      PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-4.0.21
      PassengerDefaultRuby /usr/bin/ruby
      Alternatively, you can add the above code with the following command:
      echo -en "LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-4.0.21/buildout/apache2/mod_passenger.so\nPassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-4.0.21\nPassengerDefaultRuby /usr/bin/ruby\n" >> /usr/local/apache/conf/includes/pre_main_2.conf
  7. Restart Apache
    # service httpd restart
  8. Switch to your cPanel User - Now you will need to install your application as the cPanel user, or else you will run into permission issues.
    # su cpanelusr
    # cd ~

The final step is to install the application.

Installing Redmine 

publishing the site
# rake db:migrate RAILS_ENV=production
  1. Create rails_app folder and redmine folder within it then go inside that folder
    # mkdir -p ~/rails_apps/redmine/ # cd ~/rails_apps/redmine/
  2. Download redmine 2.1.4, extract it and move the content out of it, then delete the files not being used.
    # wget http://rubyforge.org/frs/download.php/76589/redmine-2.1.4.tar.gz # tar xvzf redmine-2.1.4.tar.gz # mv redmine-2.1.4/* ./ # rm -rf redmine-2.1.4*
  3. Move example files where they can be used.
    # cd config # mv database.yml.example database.yml # mv configuration.yml.example configuration.yml
  4. Creating the MySQL Database/User/Password
    1. Log in to your Bluehost Control Panel,
    2. Within the database section of that cPanel, find the 'MySQL® Databases' Icon.
    3. Create a database, a username, and a password.
    4. Assign the user to the database. Full permissions.

    Click here for information about How to Create and Delete MySQL Databases and Users.

  5. Modifying your database.yml file
    # vim database.yml
    Modify these lines

    production: adapter: mysql database: redmine host: localhost username: root password: encoding: utf8

  6. Updating the ~/rails_apps/redmine/public/.htaccess file
    # cd ../public/ 
    # pwd
    You should see something similar to this:
    /home#/user/rails_apps/redmine/public
    # vim .htaccess
    Add these lines:
    Options -MultiViews
    PassengerResolveSymlinksInDocumentRoot on
    #Set this to whatever environment you'll be running in
    RailsEnv production
    RackBaseURI /
    SetEnv GEM_HOME /home1/examplec/ruby/gems
    Update this line to match the path for #pwd
    SetEnv GEM_HOME /home#/user/ruby/gems
  7. Creating the subdomain
    The goal is to point the subdomain to the redmine folder. if you don't have one in mind, you can simply use redmine as your subdomain;
    1. Log in to your Bluehost Control Panel
    2. Within the domain section of that cPanel, find the 'Subdomains' Icon.
    3. Choose one of your Domain Names from the drop-down list.
    4. Then create a subdomain going to the document root of redmine
  8. Creating the symlink
    Now you need to delete the redmine folder, you can delete this from within the ~/public_html directory.
    # rm -rf redmine
    Creating the symlink
    # ln -s ~/rails_app/redmine/public redmine
  9. Updating your ~/.bashrc file
    Add these lines to the bottom of your ~/.bashrc file
    export HPATH=$HOME
    export GEM_HOME=$HPATH/ruby/gems
    export GEM_PATH=$GEM_HOME:/lib64/ruby/gems/1.9.3
    export GEM_CACHE=$GEM_HOME/cache
    export PATH=$PATH:$HPATH/ruby/gems/bin
    export PATH=$PATH:$HPATH/ruby/gems
    after which source your .bashrc file.
    # source ~/.bashrc
    You will then need to check your rails version.
    # rails -v
    You should get this message.
    Rails 3.2.13
    If you see this an error like so.
    Invalid gemspec in [/home#/user/ruby/gems/specifications/mail-2.4.4.gemspec]: invalid date format in specification: "2012-03-14 00:00:00.000000000Z"
       Invalid gemspec in [/home#/user/ruby/gems/specifications/tilt-1.3.3.gemspec]: invalid date format in specification: "2011-08-25 00:00:00.000000000Z"
    Open the file from the error message, in this case /home#/user/ruby/gems/specifications/mail-2.4.4.gemspec modify this line.
    s.date = %q{2012-03-14 00:00:00.000000000Z}
    Change it to
       s.date = %q{2012-03-14}
    That should correct that error message. This easy to run command is also viable.
    # find $HOME/ruby/gems/specifications -name \*.gemspec | xargs sed -i "s/\ 00:00:00.000000000Z//"
  10. # cd ~/rails_apps/redmine/
    # bundle install
    # rake generate_session_store
  11. Running bundle install
    the # rake generate_session_store is strictly related to redmine, some other applications may use it 
    After running the rake if you get this error
    Invalid gemspec in [/home#/user/ruby/gems/specifications/jquery-rails-2.0.3.gemspec]: invalid date format in specification: "2012-08-16 00:00:00.000000000Z"
    Again open that file /home#/user/ruby/gems/specifications/jquery-rails-2.0.3.gemspec and fix the date, if you don't know how to do that read above about 10 lines.
    # bundle install
  12. Running generate_session_store or generate_secret_token
    # rake generate_session_store
    If you get an error saying that command is deprecated, run this command instead;
    # rake generate_secret_token
    
    publishing the site
       # rake db:migrate RAILS_ENV=production

Common Issues

# rails generate controller First list
/home4/lorentzo/ruby/gems/gems/execjs-1.4.0/lib/execjs/runtimes.rb:51:in `autodetect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
from /home#/user/ruby/gems/gems/execjs-1.4.0/lib/execjs.rb:5
from /home#/user/ruby/gems/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `require'
from /home#/user/ruby/gems/gems/coffee-script-2.2.0/lib/coffee_script.rb:1
from /home#/user/ruby/gems/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `require'
from /home#/user/ruby/gems/gems/coffee-script-2.2.0/lib/coffee-script.rb:1
from /home#/user/ruby/gems/gems/coffee-rails-3.2.2/lib/coffee-rails.rb:1:in `require'
from /home#/user/ruby/gems/gems/coffee-rails-3.2.2/lib/coffee-rails.rb:1
from /home#/user/ruby/gems/gems/bundler-1.2.2/lib/bundler/runtime.rb:68:in `require'
from /home#/user/ruby/gems/gems/bundler-1.2.2/lib/bundler/runtime.rb:68:in `require'
from /home#/user/ruby/gems/gems/bundler-1.2.2/lib/bundler/runtime.rb:66:in `each'
from /home#/user/ruby/gems/gems/bundler-1.2.2/lib/bundler/runtime.rb:66:in `require'
from /home#/user/ruby/gems/gems/bundler-1.2.2/lib/bundler/runtime.rb:55:in `each'
from /home#/user/ruby/gems/gems/bundler-1.2.2/lib/bundler/runtime.rb:55:in `require'
from /home#/user/ruby/gems/gems/bundler-1.2.2/lib/bundler.rb:128:in `require'
from /home#/user/rails_apps/first/config/application.rb:7
from /home#/user/ruby/gems/gems/railties-3.2.9/lib/rails/commands.rb:24:in `require'
from /home#/user/ruby/gems/gems/railties-3.2.9/lib/rails/commands.rb:24
from script/rails:6:in `require'
from script/rails:6

Solution

# gem install therubyracer
  • then run
    # bundle install

If you need further assistance, feel free to contact us via Chat or Phone:

  • Chat Support - While on our website, you should see a CHAT bubble in the bottom right-hand corner of the page. Click anywhere on the bubble to begin a chat session.
  • Phone Support -
    • US: 888-401-4678
    • International: +1 801-765-9400

You may also refer to our Knowledge Base articles to help answer common questions and guide you through various setup, configuration, and troubleshooting steps.