Support / KnowledgeBase

 
Search the KnowledgeBase Search

(dv) 2.0 Install Ruby on Rails

  • Applies to: (dv) 2.0

  • Difficulty: Medium

  • Time needed: 5 minutes

  • Tools needed: root, ssh

 
ftp
This article provides a general walkthrough on how to add Ruby on Rails (RoR) on a (dv) 2.0 Dedicated-Virtual Server

Things you will need:

IMPORTANT


Details

Step 1: Make backups


This point cannot be stressed enough. The best way to back up all of the information on the server so you can return to a previous state is by using our (dv) Snapshot Backup Add-on service. This way if things don't go well with the upgrade you can always get your server working without too much hassle.

Step 2: Prepare your server

  • If you currently do not have your root user enabled or our Developer Tools installed please visit the Root Access & Developer Tools section of your AccountCenter.  These tools include compilers and other basic things that you'll need to continue. If you have already upgraded MySQL this step has been taken care of.
  • Check to make sure you have zlib installed. To do this create a php file in your webroot with this content:
    <?php
    phpinfo();
    ?>
    Go to the page in a browser and make sure that you have zlib libraries.

Step 3: Install Packages

  • Install Ruby and Ruby gems. Log into your server via SSH as 'root' and use these commands to get the required packages and install them: ftp
    cd /usr/local/src
    wget ftp://ftp.ruby-lang.org/pub/ruby/stable/ruby-1.8.4.tar.gz
    tar xvzf ruby-1.8.4.tar.gz
    cd ruby-1.8.4
    ./configure
    make
    make install
    cd ..
    wget http://rubyforge.org/frs/download.php/5207/rubygems-0.8.11.tgz
    tar xvzf rubygems-0.8.11.tgz
    cd rubygems-0.8.11
    ruby setup.rb
  • Ruby is now installed, now to get rails:
    gem install rails
    Answer 'Y' to all questions, the output will look something like this:
    Install required dependency rake? [Yn]  Y
    Install required dependency activesupport? [Yn]  Y
    Install required dependency activerecord? [Yn]  Y
    Install required dependency actionpack? [Yn]  Y
    Install required dependency actionmailer? [Yn]  Y
    Install required dependency actionwebservice? [Yn]  Y
  • Now lets install fast cgi (fcgi):
    cd ..
    wget http://fastcgi.com/dist/fcgi-2.4.0.tar.gz
    tar xvzf fcgi-2.4.0.tar.gz
    cd fcgi-2.4.0
    ./configure && make && make install
  • Then install mod_fastcgi:
    cd ..
    wget http://fastcgi.com/dist/mod_fastcgi-2.4.2.tar.gz
    tar xvzf mod_fastcgi-2.4.2.tar.gz
    cd mod_fastcgi-2.4.2
  • The make file needs some tuning for Plesk enabled boxes, copy the sample Makefile.AP2 and then edit it:
    cp Makefile.AP2 Makefile
    vi Makefile 
  • Change the line that reads:
    top_dir = /usr/local/apache2
    to
    top_dir = /usr/lib/httpd
  • Now let's install it:
    make && make install
  • Install the ruby fcgi gem. You might get lots of errors about documentation, don't worry about them:
    gem install fcgi
    Choose option number 3
  • Install the MySQL gem:
    gem install MySQL -- --with-MySQL-include=/usr/include/MySQL --with-MySQL-lib=/usr/lib/MySQL 
  • You need to add a conf file for mod_fastcgi so apache will load it create the file /etc/httpd/conf.d/fastcgi.conf and make sure it has this content:
    User apache
    Group apache
    LoadModule fastcgi_module /usr/lib/httpd/modules/mod_fastcgi.so
    
    <IfModule mod_fastcgi.c>
         FastCgiWrapper on
         FastCgiConfig -idle-timeout 900
         FastCgiIpcDir /tmp/fastcgi_ipc/
         AddHandler fastcgi-script .fcgi .rb
    </IfModule>
  • Create the tmp directory for mod_fastcgi:
    mkdir /tmp/fastcgi_ipc
    chown -R apache.apache /tmp/fastcgi_ipc
    chmod -R 755 /tmp/fastcgi_ipc
  • Test to make sure apache is happy with the new configs:
    apachectl configtest
  • Restart apache:
    /etc/init.d/httpd restart
RoR should now be working on your server so you can immediately start installing applications. To make fcgi cache your app (read: make it really fast) you'll need to add a line to your fastcgi.conf, something like this will work:
FastCgiServer /var/www/vhosts/mt-example.com/httpdocs/rails/filename.fcgi -idle-timeout 120 -initial-env RAILS_ENV=production -processes 10

Revisions:

07-20-2009: Minor Fixes

User Comments

No visitor comments posted. Post a comment

Fields marked with an asterisk(*) are required. Comment on this article

Fill out the form below if you would like to comment on this article.
 
 
 

(code is not case-sensitive)
 
Submit
 
 

Continue