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.
- 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
- Installing Passenger - Now that Ruby is installed, we will use the following command:
# gem install passenger mysql
- Installing curl-devel
# yum install curl-devel
When prompted "Is this ok [y/N]:" type the letter "y" and press Enter. - Installing postgresql-devel
# yum install postgresql-devel
- Installing ImageMagick
# /scripts/installimagemagick
- Installing passenger modules, for apache
# passenger-install-apache2-module
The system will check to see what you are missing. Press the Enter.- 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."
- Press the Enter.
- 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
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
- Restart Apache
# service httpd restart
- 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
- Create rails_app folder and redmine folder within it then go inside that folder
# mkdir -p ~/rails_apps/redmine/ # cd ~/rails_apps/redmine/
- 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*
- Move example files where they can be used.
# cd config # mv database.yml.example database.yml # mv configuration.yml.example configuration.yml
- Creating the MySQL Database/User/Password
- Log in to your Bluehost Control Panel,
- Within the database section of that cPanel, find the 'MySQL® Databases' Icon.
- Create a database, a username, and a password.
- Assign the user to the database. Full permissions.
Click here for information about How to Create and Delete MySQL Databases and Users.
- Modifying your database.yml file
# vim database.yml
production: adapter: mysql database: redmine host: localhost username: root password: encoding: utf8
- Updating the ~/rails_apps/redmine/public/.htaccess file
# cd ../public/ # pwd
/home#/user/rails_apps/redmine/public
# vim .htaccess
Options -MultiViews PassengerResolveSymlinksInDocumentRoot on #Set this to whatever environment you'll be running in RailsEnv production RackBaseURI / SetEnv GEM_HOME /home1/examplec/ruby/gems
SetEnv GEM_HOME /home#/user/ruby/gems
- 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;- Log in to your Bluehost Control Panel
- Within the domain section of that cPanel, find the 'Subdomains' Icon.
- Choose one of your Domain Names from the drop-down list.
- Then create a subdomain going to the document root of redmine
- Creating the symlink
Now you need to delete the redmine folder, you can delete this from within the ~/public_html directory.# rm -rf redmine
# ln -s ~/rails_app/redmine/public redmine
- Updating your ~/.bashrc file
Add these lines to the bottom of your ~/.bashrc fileexport 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
# source ~/.bashrc
# rails -v
Rails 3.2.13
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"
s.date = %q{2012-03-14 00:00:00.000000000Z}
s.date = %q{2012-03-14}
# find $HOME/ruby/gems/specifications -name \*.gemspec | xargs sed -i "s/\ 00:00:00.000000000Z//"
-
# cd ~/rails_apps/redmine/ # bundle install # rake generate_session_store
- 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 errorInvalid 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"
# bundle install
- 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.