Main Page | Recent changes | Edit this page | Page history

Printable version | Disclaimers

Not logged in
Log in | Help
 

SiD

From Gemin-Wiki

Table of contents

SiD

What Is SiD?

SiD stands for Schools Information Database, it's a quick Ruby/Rails project we built to (A) Learn about Ruby and Rails and (B) Track our relationships with out customers, who's paid, who we need to talk to, when their subscriptions run out etc.


Licence

We haven't opened the licence of yet, and doubt there's any real reason to do so to be honest.

Deploying Rails

Making Rails run on a standard Debian server is fairly easy. Just follow these simple instructions, as root of course. (Mostly worked out from http://wiki.rubyonrails.org/rails/pages/HowToSetupDebianApache2Rails )

Install Rails

 apt-get install libmysql-ruby1.8 libtest-unit-ruby1.8  libyaml-ruby1.8   libyaml-ruby libpgsql-ruby1.8 libpgsql-ruby ruby1.8 ruby ri1.8 ri irb1.8 irb postgresql ruby1.8-dev libcfgi-ruby1.8 libfcgi0 rdoc

Install Gems

 cd /usr/local/src/
 wget http://rubyforge.org/frs/download.php/2412/rubygems-0.8.4.tgz
 tar -xzf rubygems-0.8.4.tgz
 cd rubygems-0.8.4
 ruby setup.rb config
 ruby setup.rb setup
 ruby setup.rb install
 gem install rails


Setting Up Apache

You'll have to set up a new domain for the server most likely, and you'll want to put the directory structure created by rails create-project system into /var/www-X/ where X is the name of the project.

Next, we'll have to edit the config for that domain. Here's the one for SiD running on Buttercup:

 <VirtualHost *>
       ServerName sid.gemin-i.org
       ServerAlias www.sid.gemin-i.org
       ServerAdmin adam@gemin-i.org
       DocumentRoot /var/www-sid/SiD/public
       <Directory />
               Options FollowSymLinks
               AllowOverride None
       </Directory>
       <Directory //var/www-sid/SiD/public>
               Options ExecCGI FollowSymLinks
               AddHandler cgi-script .cgi
               AllowOverride all
               Order allow,deny
               Allow from all
       </Directory>
       ErrorLog /var/log/apache2/sid.error.log
       # Possible values include: debug, info, notice, warn, error, crit,
       # alert, emerg.
       LogLevel warn
       CustomLog /var/log/apache2/sid.access.log combined
       ServerSignature On
       Alias /icons/ "/usr/share/apache2/icons/"
       <Directory "/usr/share/apache2/icons">
           Options Indexes MultiViews
           AllowOverride None
           Order allow,deny
           Allow from all
       </Directory>
 </VirtualHost>

Installing Mod-Rewrite

We have to enable mod-rewrite to make Ruby work, since it uses it to force the URLs into a sensible position. As root:

 a2enmod rewrite
 /etc/init.d/apache2 restart

Install the Rails app

IE checkout SiD. You should ensure that the tmp directory is writeable by the web-user, and so are the logs in the log directory. THIS IS IMPORTANT, you'll get basically unexplained failures if the tmp directory isn't writeable. Trust me, I spent half a day figuring it out.

Installing FastCGI (well, actually fcgid)

 apt-get install libapache2-mod-fcgid

Edit FastCGI config

/etc/apache2/mods-available/fcgid.conf should be:

 <IfModule mod_fcgid.c>
   AddHandler fcgid-script .fcgi
   SocketPath /var/lib/apache2/fcgid/sock
   DefaultInitEnv  RAILS_ENV production
   IdleTimeout 600
   ProcessLifeTime 3600
   MaxProcessCount 8
   IPCConnectTimeout 8
   IPCCommTimeout 48
 </IfModule>

Enable FastCGI

 a2enmod fcgid libfcgi-ruby1.8
 /etc/init.d/apache2 restart

Edit the app's public/.htaccess file

We want to change the rewrite rule so that instead of calling the normal .cgi it calls dispatch.fcgi - so change the line saying

 RewriteRule ^(.*)$ dispatch.cgi [QSA,L]

to make it say

 RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]

That is, add the f.

Also, comment out the "addHandler" lines for CGI *and* fcgi - it seems to break when they're added twice and they're added once already in the /etc/apache2/mods-enabled/* directory.


Ensure App's Ruby path is right

Since the app may have been created outside a 'nix environment, the first line in the public/dispatch.* files (IE the HashBang) may point at C: or something equally bizarre. Make sure it points at the ruby interpreter /usr/bin/ruby


Play!

That should be it, your app should be running. Mine seems to be.

Retrieved from "http://dev.gemin-i.org/wiki/index.php/SiD"

This page has been accessed 988 times. This page was last modified 14:51, 11 Oct 2006.


[Main Page]
Main Page
Recent changes
Random page
Current events

Edit this page
Discuss this page
Page history
What links here
Related changes

Special pages
Bug reports