(dv) 2.0 Install Ruby on Rails
This article provides a general walkthrough on how to add Ruby on Rails (RoR) on a (dv) 2.0 Dedicated-Virtual Server
IMPORTANT
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.
STOP:
For (dv) 3.x see (dv) 3.x HOWTO: Ruby On Rails using mongrel_cluster
Things you will need:
- Root access and SSH access to your (dv)
- A basic understanding of the Vim editor
- MySQL must be upgraded to at least version 4.1 to install RoR, for help upgrading MySQL please refer to our MySQL 4.1x article
IMPORTANT
- If done properly this upgrade will not interfere with the (mt) Media Temple Update Option Program, the server can stay enrolled.
- When in doubt please consult http://rubyonrails.org/ .
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:
Go to the page in a browser and make sure that you have zlib libraries.<?php phpinfo(); ?>
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:
Answer 'Y' to all questions, the output will look something like this:gem install railsInstall 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:
totop_dir = /usr/local/apache2top_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:
Choose option number 3gem install fcgi - 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
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
Fields marked with an asterisk(*) are required. Comment on this article