Ruby on Rails
HowToInstallOnCsoftNet (Version #2)

This article explains how to get Ruby on Rails to work on a http://csoft.net/ virtualhost.

  1. Check to see if at least ruby 1.8.2 is already installed on your machine:
    ruby -v

    If it is, skip the next step, otherwise:
  1. Get the latest stable ruby release from http://www.ruby-lang.org/ and install it in your home directory (this example will use $HOME/user for everything):
    
            gzcat ruby-1.8.3.tar.gz | tar -xvf -
            cd ruby-1.8.3
            nice ./configure --prefix=$HOME/user
            nice make
            nice make test
            nice make install
        
  1. Get and install the latest ruby-gems from http://rubyforge.org/frs/?group_id=126
    
            gzcat rubygems-0.8.11.tgz | tar -xvf -
            cd rubygems-0.8.11
            export GEM_HOME=$HOME/user/gems
            ruby setup.rb config --prefix=$HOME/user
            ruby setup.rb setup
            ruby setup.rb install
        
  1. Install Ruby on Rails via ruby-gems:
    gem install rails --include-dependencies --no-rdoc
  1. Install the FastCGI gem:
    gem install fcgi --no-rdoc -- --with-fcgi-dir=/usr/local
  2. Adjust your .profile so ruby, gem and rails can be found:
    # Put $HOME/user/bin and $HOME/user/gems/bin to your PATH, like so (sh/ksh/bash, goes into .profile):
    
                PATH=$HOME/user/bin:$HOME/user/gems/bin:$PATH
                export PATH
            


    # Also add GEM_HOME to your environment, like so (sh/ksh/bash again, into .profile):
    
                GEM_HOME=$HOME/user/gems
                export GEM_HOME
            


    Log out and back in or just cut&paste the commands above into your shell to update your environment.
  1. Test!
    
            which ruby          # should point to the ruby in $HOME/user
            ruby -v         # should be at least 1.8.2
            gem environment         # installation directory and gem path should point to $HOME/user/gems
            cd ~/www/YOURWEBHOST
            rails railstest         # generate a ruby on rails structure
            cd railstest
            ./script/generate controller test           # generate a test controller
        
  1. Adjust .htaccess to contain these lines (most are already there):
    
            Options +FollowSymLinks +ExecCGI
            # we don't need to add handlers for FastCGI, thats alread in csoft's global httpd.conf
            
            RewriteEngine On
            
            # add this line
            RewriteBase /railstest/public
RewriteRule ^$ index.html [QSA] RewriteRule ([.]+)$ $1.html [QSA] RewriteCond %{REQUEST_FILENAME} !-f # change dispatch.cgi to dispatch.fcgi so we use FastCGI (CGI works too, but it’s painfully slow) RewriteRule ^(.*)$ dispatch.fcgi [QSA,L] ErrorDocument 500 “

Application error

Rails application failed to start properly”
  1. Now adjust dispatch.fcgi (and optionally dispatch.cgi if you insist on using CGI over FastCGI):
    Make sure the shebang line points to the ruby in your home directory, then add the next two lines so the top of dispatch.fcgi looks like this:
    
            #!/home1/sdfjkl/user/bin/ruby
            ENV['GEM_HOME'] = '/YOUR/HOME/user/gems'         # adjust this - so rubygems can find the gems
            require 'rubygems'          # this is so the fcgi_handler includes the fcgi gem instead of looking for fcgi in site-ruby, which we didn't install
        
  1. You’re done! Going to http://YOUR.DOMAIN/railstest/public/test should yield “Unknown action No action responded to index”. That means mod_fastcgi called dispatch.fcgi which then looked for a controller named test and tried to call it’s default action (index).

This article explains how to get Ruby on Rails to work on a http://csoft.net/ virtualhost.

  1. Check to see if at least ruby 1.8.2 is already installed on your machine:
    ruby -v

    If it is, skip the next step, otherwise:
  1. Get the latest stable ruby release from http://www.ruby-lang.org/ and install it in your home directory (this example will use $HOME/user for everything):
    
            gzcat ruby-1.8.3.tar.gz | tar -xvf -
            cd ruby-1.8.3
            nice ./configure --prefix=$HOME/user
            nice make
            nice make test
            nice make install
        
  1. Get and install the latest ruby-gems from http://rubyforge.org/frs/?group_id=126
    
            gzcat rubygems-0.8.11.tgz | tar -xvf -
            cd rubygems-0.8.11
            export GEM_HOME=$HOME/user/gems
            ruby setup.rb config --prefix=$HOME/user
            ruby setup.rb setup
            ruby setup.rb install
        
  1. Install Ruby on Rails via ruby-gems:
    gem install rails --include-dependencies --no-rdoc
  1. Install the FastCGI gem:
    gem install fcgi --no-rdoc -- --with-fcgi-dir=/usr/local
  2. Adjust your .profile so ruby, gem and rails can be found:
    # Put $HOME/user/bin and $HOME/user/gems/bin to your PATH, like so (sh/ksh/bash, goes into .profile):
    
                PATH=$HOME/user/bin:$HOME/user/gems/bin:$PATH
                export PATH
            


    # Also add GEM_HOME to your environment, like so (sh/ksh/bash again, into .profile):
    
                GEM_HOME=$HOME/user/gems
                export GEM_HOME
            


    Log out and back in or just cut&paste the commands above into your shell to update your environment.
  1. Test!
    
            which ruby          # should point to the ruby in $HOME/user
            ruby -v         # should be at least 1.8.2
            gem environment         # installation directory and gem path should point to $HOME/user/gems
            cd ~/www/YOURWEBHOST
            rails railstest         # generate a ruby on rails structure
            cd railstest
            ./script/generate controller test           # generate a test controller
        
  1. Adjust .htaccess to contain these lines (most are already there):
    
            Options +FollowSymLinks +ExecCGI
            # we don't need to add handlers for FastCGI, thats alread in csoft's global httpd.conf
            
            RewriteEngine On
            
            # add this line
            RewriteBase /railstest/public
RewriteRule ^$ index.html [QSA] RewriteRule ([.]+)$ $1.html [QSA] RewriteCond %{REQUEST_FILENAME} !-f # change dispatch.cgi to dispatch.fcgi so we use FastCGI (CGI works too, but it’s painfully slow) RewriteRule ^(.*)$ dispatch.fcgi [QSA,L] ErrorDocument 500 “

Application error

Rails application failed to start properly”
  1. Now adjust dispatch.fcgi (and optionally dispatch.cgi if you insist on using CGI over FastCGI):
    Make sure the shebang line points to the ruby in your home directory, then add the next two lines so the top of dispatch.fcgi looks like this:
    
            #!/home1/sdfjkl/user/bin/ruby
            ENV['GEM_HOME'] = '/YOUR/HOME/user/gems'         # adjust this - so rubygems can find the gems
            require 'rubygems'          # this is so the fcgi_handler includes the fcgi gem instead of looking for fcgi in site-ruby, which we didn't install
        
  1. You’re done! Going to http://YOUR.DOMAIN/railstest/public/test should yield “Unknown action No action responded to index”. That means mod_fastcgi called dispatch.fcgi which then looked for a controller named test and tried to call it’s default action (index).