Ruby on Rails 1.2 on Solaris 10 Howto [Updated]

I've received an amazing amount of feedback the last few months from my original posting in August on how to get Rails up on running on Solaris 10. With the recent release of Rails 1.2.1, it's probably time to tweak the instructions and incorporate some of the comments.
What I describe here is a way for you to get up and running with Rails on Solaris 10 (and later, including Developer Express) systems, which of course also gives you a full Ruby environment. In contrast to a script that does all of this for you, putting the pieces together yourself is a simple exercise and will give you a good understanding of a typical Ruby installation and its components. The major components described here are:

Rails fits right home with Solaris 10 because of the included Postgres database system; there is no need for downloading and installing a database - it's already there! Solaris 10 also includes the GCC compiler which I use here for interoperability with Ruby gems that you'll be pulling from the net, including Rails itself. Finally, you can use Dtrace right out of the box to help you analyze your Postgres and Rails performance issues!
ftp_proxy/http_proxy environment variables to make the wget commands listed here to work correctly. Substitute your proxy accordingly:export ftp_proxy="http://(your web proxy):(your web proxy port)"
export http_proxy=$ftp_proxy
/opt/local. You can change this to your needs by altering the prefix definition below.Postgres. File /etc/release on your Solaris system should say "06/06" or "11/06".Watch a Rubyist at work and you'll see a lot of tinkering and experimenting at the command line. Input recall is a must in this mode, so you'll want to make sure that you have the GNU Readline library installed.
wget ftp://ftp.cwru.edu/pub/bash/readline-5.2.tar.gz
gzcat readline-5.2.tar.gz | tar xf -
cd readline-5.2
configure --prefix=/opt/local
make
su
make install
irb (interactive ruby), ri (ruby doc lookup), and rdoc (documentation generator).wget ftp://ftp.ruby-lang.org/pub/ruby/ruby-1.8.5-p12.tar.gz
gzcat ruby-1.8.5-p12.tar.gz | tar xf -
cd ruby-1.8.5-p12
configure --prefix=/opt/local --enable-pthread --with-readline-dir=/opt/local
make
make test
su
make install
make install-doc # This takes a while but is worth the wait
wget http://rubyforge.org/frs/download.php/16452/rubygems-0.9.1.tgz
gzcat rubygems-0.9.1.tgz | tar xf -
cd rubygems-0.9.1
su
/opt/local/bin/ruby setup.rb
su
PATH=$PATH:/opt/local/bin
export PATH
gem install rails --include-dependencies
wget http://ruby.scripting.ca/postgres/archive/ruby-postgres-0.7.1.tar.gz
gzcat ruby-postgres-0.7.1.tar.gz | tar xf -
cd ruby-postgres-0.7.1
ruby extconf.rb --with-pgsql-include-dir=/usr/include/pgsql
gmake
su
PATH=$PATH:/usr/sbin
export PATH
gmake install
groupadd postgres
useradd -c "PostgreSQL User" -d /export/home/postgres -g postgres -m -s /bin/bash postgres
chown postgres /var/lib/pgsql/data
chmod 700 /var/lib/pgsql/data
su postgres
initdb -D /var/lib/pgsql/data
su - postgres
pg_ctl -D /var/lib/pgsql/data -l /var/tmp/pglog start
createuser your-login-name # This lets you perform DB operations
mkdir -p src/rails
cd src/rails
rails hello
cd src/rails/hello
ruby script/server
http://localhost:3000
and verify that you see a similar display to this:

MySQL for our database. This is the default for Rails, so we need to change this to use our built-in PostgresQL database instead.
I'm closely following Chapter 6 (first or second edition) from the Agile Development with Rails book by Dave Thomas and Dave Heinemeier-Hansson.
This will create the depot application that the authors use as an example, and will also construct the three Postgres databases:
mkdir src/rails
rails depot
createdb depot_development
createdb depot_test
createdb depot_production
src/rails/depot/db/create.sql that looks like this:create table products (
id SERIAL,
title varchar(100) not null,
description text not null,
image_url varchar(200) not null,
price decimal(10,2) not null,
primary key(id)
);
auto_increment modifier, given in the book, to the PostgreSQL SERIAL type above.
One more change: Modify the src/rails/depot/config/database.yml file to point to your PostgreSQL database. Ignoring the comments, it should look something like this, if hank is your login name:
development:
adapter: postgresql
database: depot_development
username: hank
password:
host: localhost
test:
adapter: postgresql
database: depot_test
username: hank
password:
host: localhost
production:
adapter: postgresql
database: depot_production
username: hank
password:
host: localhost
products table definition:
psql depot_development < db/create.sql
cd src/rails/depot
ruby script/generate scaffold Product Admin
ruby script/server
http://localhost:3000/adminshould show you the scaffolding of your new web app and give you the green light that you've successfully configured your Rails/Postgres on Solaris environment.
Want to learn more? Check out the Top 30 Rails Tutorials
Happy Ruby on Railing, and keep those comments coming.
Posted at 04:02PM Jan 29, 2007 by Peter Schow in Software | Comments[1]
RubyConf 2006 wrapup
RubyConf 2006 ended yesterday in Denver. A good summary can be found at this collection of blogs, which includes some question-and-answer transcripts. Ruby has some interesting next-steps in its evolution, as far as compatibility, governance, and virtual machine choices go, but that doesn't matter right now - enjoy version 1.8!
Other notes:
Posted at 08:32PM Oct 23, 2006 by Peter Schow in Software |
RubyConf 2006, Day 1
Today was the first day of the Sixth International Ruby Conference in Denver, Colorado, also known as RubyConf 2006. It's a single-track conference which makes it nice because you don't have to make the hard decisions about which sessions to attend.
It was great to meet some fellow Sun employees there.
Posted at 10:22PM Oct 20, 2006 by Peter Schow in Software |