Netwisp Forums  

Go Back   Netwisp Forums > Got a question? > FAQs and HOWTOs

Reply
 
Thread Tools Display Modes
  #1  
Old 12-06-2007, 11:08 PM
Hal Hal is offline
Administrator
Site Admin
 
Join Date: Dec 2002
Location: Schaumburg, IL.
Posts: 181
Send a message via ICQ to Hal Send a message via AIM to Hal Send a message via MSN to Hal
Default Installing Ruby on Rails on Ensim

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:

Code:
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.

Code:
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 Bouma
www.netwisp.com
Reply With Quote
  #2  
Old 12-06-2007, 11:11 PM
Hal Hal is offline
Administrator
Site Admin
 
Join Date: Dec 2002
Location: Schaumburg, IL.
Posts: 181
Send a message via ICQ to Hal Send a message via AIM to Hal Send a message via MSN to Hal
Default Step #2 : Installing mod_ruby

Download and compile mod_ruby apache module:

Code:
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

Code:
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 Bouma
www.netwisp.com
Reply With Quote
  #3  
Old 12-07-2007, 01:22 AM
Hal Hal is offline
Administrator
Site Admin
 
Join Date: Dec 2002
Location: Schaumburg, IL.
Posts: 181
Send a message via ICQ to Hal Send a message via AIM to Hal Send a message via MSN to Hal
Default Step #3 : Installing Ruby Gems

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:

Code:
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:

Code:
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:

Code:
# 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 Bouma
www.netwisp.com
Reply With Quote
  #4  
Old 12-07-2007, 01:27 AM
Hal Hal is offline
Administrator
Site Admin
 
Join Date: Dec 2002
Location: Schaumburg, IL.
Posts: 181
Send a message via ICQ to Hal Send a message via AIM to Hal Send a message via MSN to Hal
Default Step #4 : Updating Ensim's Template List

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:

Code:
# 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:

Code:
#!/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:

Code:
/usr/local/sbin/set_pre_maintenance 
/usr/local/sbin/set_maintenance 
/usr/local/sbin/set_post_maintenance 
service epld restart
__________________
Hal Bouma
www.netwisp.com
Reply With Quote
  #5  
Old 12-07-2007, 01:32 AM
Hal Hal is offline
Administrator
Site Admin
 
Join Date: Dec 2002
Location: Schaumburg, IL.
Posts: 181
Send a message via ICQ to Hal Send a message via AIM to Hal Send a message via MSN to Hal
Default Step 5 : Creating a rails application

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:

Code:
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 Bouma
www.netwisp.com
Reply With Quote
  #6  
Old 12-07-2007, 01:40 AM
Hal Hal is offline
Administrator
Site Admin
 
Join Date: Dec 2002
Location: Schaumburg, IL.
Posts: 181
Send a message via ICQ to Hal Send a message via AIM to Hal Send a message via MSN to Hal
Default Step #6 : Extras

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:

Code:
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).
__________________
Hal Bouma
www.netwisp.com
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 11:08 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.