PDA

View Full Version : Installing Ruby on Rails on Ensim


Hal
12-07-2007, 12:08 AM
Step #1 Install Ruby/eRuby:

Ruby and eRuby requires the following packages:

ruby
ruby-devel
ruby-libs
ruby-abi
eruby
eruby-devel
eruby-libs

If you want to use the version that comes with your distro, install from yum:

yum install ruby ruby-libs eruby eruby-libs


Otherwise, download latest rpms from mirror.netwisp.com for your particular distro and install using rpm -Uvh.

You'll also need to download and build the ruby-mysql package.


cd /usr/src/
wget http://dev.centos.org/centos/4/testing/SRPMS/ruby-mysql-2.7-8.el4.centos.src.rpm
rpmbuild --rebuild ruby-mysql-2.7-8.el4.centos.src.rpm
rpm -Uvh /usr/src/redhat/RPMS/i386/ruby-mysql*.rpm


Note: Although this is listsed for CentOS 4, it will also build for CentOS 5.

Hal
12-07-2007, 12:11 AM
Download and compile mod_ruby apache module:

wget http://www.modruby.net/archive/mod_ruby-1.2.6.tar.gz
tar -zxvf mod_ruby-1.2.6.tar.gz
cd mod_ruby-1.2.6.tar.gz
./configure.rb --with-apxs=/usr/sbin/apxs --with-apr-includes=/usr/include/apr-1
make
make install


Edit /etc/httpd/conf.d/ruby.conf

LoadModule ruby_module modules/mod_ruby.so

# This will allow execution of mod_perl to compile your scripts to
# subroutines which it will execute directly, avoiding the costly
# compile process for most requests.

RubyRequire apache/ruby-run
Alias /ruby /var/www/ruby

# Execute *.rbx files as Ruby scripts
#

<Files *.rbx>
SetHandler ruby-object
RubyHandler Apache::RubyRun.instance
</Files>

# Handle *.rhtml as eruby files
#

<Files *.rhtml>
RubyRequire apache/eruby-run
SetHandler ruby-object
RubyHandler Apache::ERubyRun.instance
</Files>


Restart Apache

Hal
12-07-2007, 02:22 AM
First you'll need to install Ruby Gems on the server.

You can download the source RPM from here:

http://people.redhat.com/dlutter/yum/SRPMS/

and build the RPM for your distro. The current version posted there is 0.9.4-1:


cd /usr/src
wget http://people.redhat.com/dlutter/yum/SRPMS/rubygems-0.9.4-1.src.rpm
rpmbuild --rebuild rubygems-0.9.4-1.src.rpm
rpm -Uvh /usr/src/redhat/RPMS/i386/rubygems-0.9.4-1.rpm


Once Gems is installed, you'll need to install the Gem packages needed for rails:


gem install rails --include-dependencies


Now we'll need to create RPM packages for those gems. First download the .spec files needed to create the RPMs from dlutter's site:


# Copy compiled Gems into SOURCE directory
cp /usr/lib/ruby/gems/1.8/cache/actionmailer-1.3.6.gem /usr/src/redhat/SOURCES/
cp /usr/lib/ruby/gems/1.8/cache/actionpack-1.13.6.gem /usr/src/redhat/SOURCES/
cp /usr/lib/ruby/gems/1.8/cache/actionwebservice-1.2.6.gem /usr/src/redhat/SOURCES/
cp /usr/lib/ruby/gems/1.8/cache/activesupport-1.4.4.gem /usr/src/redhat/SOURCES/
cp /usr/lib/ruby/gems/1.8/cache/rails-1.2.6.gem /usr/src/redhat/SOURCES/
cp /usr/lib/ruby/gems/1.8/cache/rake-0.7.3.gem /usr/src/redhat/SOURCES/

# Download and install SPEC files
cd /usr/src/redhat/SPECS
wget http://people.redhat.com/dlutter/yum/spec/rubygem-actionmailer.spec
wget http://people.redhat.com/dlutter/yum/spec/rubygem-actionpack.spec
wget http://people.redhat.com/dlutter/yum/spec/rubygem-actionwebservice.spec
wget http://people.redhat.com/dlutter/yum/spec/rubygem-activesupport.spec
wget http://people.redhat.com/dlutter/yum/spec/rubygem-rails.spec
wget http://people.redhat.com/dlutter/yum/spec/rubygem-rake.spec

# Create RPMS
rpmbuild -bb rubygem-actionmailer.spec
rpmbuild -bb rubygem-actionpack.spec
rpmbuild -bb rubygem-actionwebservice.spec
rpmbuild -bb rubygem-activesupport.spec
rpmbuild -bb rubygem-rails.spec
rpmbuild -bb rubygem-rake.spec

# Install RPMs

rpm -Uvh /usr/src/redhat/RPMS/noarch/rubygem-*.rpm

Hal
12-07-2007, 02:27 AM
Now that all the RPMs have been built, you'll need to update Ensim's filelists so that the virtual file system gets updated with the Ruby packages:

You need to add the following lines to your /etc/virtualhosting/filelists/siteinfo.custom.sh:


# Ruby on Rails Support
echo "N:S,rpm:ruby"
echo "N:S,rpm:ruby-libs"
echo "N:S,rpm:ruby-abi"
echo "N:S,rpm:ruby-mysql"

echo "N:S,rpm:eruby"
echo "N:S,rpm:eruby-libs"

echo "N:S,rpm:rubygems"
echo "N:S,rpm:rubygem-actionmailer"
echo "N:S,rpm:rubygem-actionpack"
echo "N:S,rpm:rubygem-actionwebservice"
echo "N:S,rpm:rubygem-activerecord"
echo "N:S,rpm:rubygem-activesupport"
echo "N:S,rpm:rubygem-rails"
echo "N:S,rpm:rubygem-rake"



If you don't have a siteinfo.custom.sh file, please add this to the top of the file before adding the above listed lines for Ruby:


#!/bin/bash
read
while [ $? == 0 ]; do
echo $REPLY
read
done


Then chmod +x the file so that Ensim can execute it.

You will now need to run maintenance mode to update the sites:


/usr/local/sbin/set_pre_maintenance
/usr/local/sbin/set_maintenance
/usr/local/sbin/set_post_maintenance
service epld restart

Hal
12-07-2007, 02:32 AM
First SSH in as the site owner or chroot into the site you wish to create the rails package and su yourself as the site owner.

Now perform the following steps:


cd /var/www/
rails railsapp
cd railsapp
ruby script/generate controller test
cd ../html
ln -s ../testapp/public rails


If you now visit www.domain.com/rails you should see the rails test page.

Hal
12-07-2007, 02:40 AM
Adding Gems

While each site can install their own gem packages, you may find it useful to add commonly used gems to your server-wide install. If you do that, you'll need to download the gem2spec program from dlutter's site and run it to generate a spec file for the gem you wish to install. Once you've created a spec file, you can follow the same steps listed earlier that was used to add the set of gem RPMs to the server. After creating the RPM packages and installing them, you can then add them to the siteinfo.custom.sh file and rebuild the file system template so that each site gets them.

FastCGI support

If you find yourself needing fastcgi support for Ruby applications, you'll need to enable it in Apache. You can do this by creating a file called /etc/httpd/conf.d/fastcgi.conf and placing the following text in it:


LoadModule fastcgi_module modules/mod_fastcgi.so

<IfModule mod_fastcgi.c>
AddHandler fastcgi-script .fcgi
</IfModule>


You will also need to install the fcgi gems package and make it available to all the sites (using the steps listed above).