PreviousINDEXNext
Configuring DNS and a DHCP serverDual booting and Daylight Saving Time (reprise)

Installing Rails on Solaris 9

As part of demoing my companies software product, I'd had to create a browser-based capability to fire data at it. I'd built this on the demo platform (a Sun Fire V210 running Solaris 9), using Python to develop a number of cgi-bin programs. While this worked, it was ugly, fragile and difficult to extend. I therefore cast about for ways to make a more robust and extensible demo package.

After reading around, I decided to give Ruby on Rails a try. While I'd prefer to stick to Python, Ruby on Rails' python equivalent, web.py did not seem to be as complete. The one problem with Ruby on Rails is that a number of prerequisite open source packages are required. However, there is sufficient resource on the web to make their installation relatively trivial.

Prerequisites

From www.sunfreeware.com:

From www.sun.com:

These packages must be installed as root, using the Solaris pkgadd command, e.g.

  pkgadd -d ./SFWgcc

Notes

The gcc install will claim it needs Berkeley db support, via SFWdb1, but this is not necessary for the use we put it to.

GNU make is installed as gmake; therefore cd to the install directory (probably /opt/sfw/bin) and "ln -s gmake make".

N.B: I had already installed emacs on the Sun server, so there may be other dependencies which I had already satisfied without knowing.

Installing Rails

Once ruby is installed and working, you need to get Ruby GEM from rubyforge (you might want to check if there is a later version). Unpack to convenient directory, cd to it and type:

  ruby setup.rb

Once GEM is installed, it can be used to install Rails:

  gem install rails --include-dependencies

To allow Oracle (our standard database) to be used as a database backend, ruby-oci is needed. Get Ruby-oci from rubyforge. Ruby-oci needs to be compiled; that's why gcc and GNU make is required.

Unpack to convenient directory, cd to it, and type make.

Running Rails

To create a Rails application:

  rails path/to/your/new/application
  cd path/to/your/new/application
  ruby script/server

Connect to the server on http://x.x.x.x:3000

Simple, eh?

I'm not documenting how to write a Rails application here. There are many tutorials available (e.g. from OnLamp). I'd also recommend Agile Web Development with Rails : A Pragmatic Guide.

Defining an Oracle user for Rails

Since figuring out how to create a new Oracle user can take a while, here's an SQL script to do it:

rem Create user for Ruby on Rails
create user rails
    identified by rails
    default tablespace O_DATA
    temporary tablespace TEMP
    quota unlimited on O_DATA
    quota unlimited on TEMP;

grant create session to rails;
grant create table to rails;
grant create view to rails;
grant create sequence to rails;

And just in case you are not sure what tablespaces are available, here's another script which lists them and their sizes. This script needs to be run as an Oracle user with system privileges. I found this on the web, but I can't remember where now.

Rem list remaining space in all tablespaces
select ts.tablespace_name, to_char(sum(nvl(fs.bytes,0))/1048576, '99,999,990.99'
) as MB_FREE,
    count(*) as FRAGMENTS, to_char(max(nvl(fs.bytes,0))/1048576, '99,999,990.99'
) as BIGGEST_BIT
    from dba_free_space fs, dba_tablespaces ts
    where fs.tablespace_name(+) = ts.tablespace_name
    group by ts.tablespace_name;
PreviousINDEXNext
Configuring DNS and a DHCP serverDual booting and Daylight Saving Time (reprise)