Welcome to Machine Unix

Search Below

Installing Rails3 on Solaris 10 9/10

A lot of things changed last time I played with Rails since version 2.3.2. This entry is about installing Rails3 on a Solaris 10 zone. Here are the steps to do so:


First you will need to install Ruby 1.9.2 if you have not done so, instructions are in my earlier blog post.

Then you will need to install sqlite3 since the bundler will use sqlite3 as the default install, you can probably change this to MySql as well. But for the easiness sake, I will go ahead and do sqlite install. You can get the source code for sqlite3 from here. After downloading the source code, here is how you install it:

[rails]# wget http://www.sqlite.org/sqlite-autoconf-3070602.tar.gz

[rails]# gunzip -c sqlite-autoconf-3070602.tar.gz | tar xf –

[rails]# cd sqlite-autoconf-3070602

[rails]# ./configure –prefix=/opt/local/sqlite3 –enable-threadsafe –includedir=/opt/local/include/

[rails]# make

[rails]# make install

The Sqlite3 installation should go very smoothly.  Next, you will need to update your /etc/profile for your PATH and LD_LIBRARY_PATH for sqlite3. Here is how the relevant part looks like on my system:

[rails]# cat /etc/profile



This is the end of the preparation, now we install RAILS3:


We get to use the very easy gem command:

[rails]# gem install rails

Successfully installed activesupport-3.0.7
Successfully installed builder-2.1.2
Successfully installed i18n-0.5.0


23 gems installed
Installing ri documentation for activesupport-3.0.7…
Installing ri documentation for builder-2.1.2…
Installing ri documentation for i18n-0.5.0…


Installing RDoc documentation for rails-3.0.7…

# gem install sqlite3-ruby — –with-sqlite3-include=/opt/local/include

Let’s go ahead and create a directory where the applications will go and create the first application:

[rails]# mkdir RailsProjects

[rails]# cd RailsProjects

[rails]# rails new my_first_app

create  README
create  Rakefile
create  config.ru
create  .gitignore
create  Gemfile
create  app
create  app/controllers/application_controller.rb


At this point Rails3 is installed, an application is created but we need to configure the app. This version of rails uses this wonderful file called Gemfile that will help you to install gems like sqlite3 and bunch of others to your liking, and it will make your life much easier.

[rails]# cd my_first_app

[rails]# ls

Gemfile       README        app           config.ru     doc           log           script        tmp

Rakefile      config        db            lib           public        test          vendor

Let’s edit that Gemfile, here is what mine looks like:

[rails]# cat Gemfile

source ‘http://rubygems.org’

gem ‘rails’, ‘3.0.7’

# Bundle edge Rails instead:
# gem ‘rails’, :git => ‘git://github.com/rails/rails.git’

gem ‘sqlite3′

# Use unicorn as the web server
# gem ‘unicorn’

# Deploy with Capistrano
# gem ‘capistrano’

# To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
# gem ‘ruby-debug’
# gem ‘ruby-debug19′, :require => ‘ruby-debug’

# Bundle the extra gems:
gem ‘bj’
# gem ‘nokogiri’
# gem ‘sqlite3-ruby’, :require => ‘sqlite3′
# gem ‘aws-s3′, :require => ‘aws/s3′

# Bundle gems for the local environment. Make sure to
# put test-only gems in this group so their generators
# and rake tasks are available in development mode:
# group :development, :test do
#   gem ‘webrat’
# end

You can uncomment whatever you need in this file and execute the following command:

[rails]# bundle install

Fetching source index for http://rubygems.org/
Using rake (0.8.7)
Using abstract (1.0.0)
Using activesupport (3.0.7)
Using builder (2.1.2)

Installing sqlite3 (1.3.3) with native extensions
Installing sqlite3-ruby (1.3.3)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.

Ok, great now it is telling me where I can find my gem is:

[rails]# bundle show sqlite3


Now, we start webrick from the directory where your app resides, but it seems like the methodology of starting the server also changed:

[rails]# rails server

=> Booting WEBrick
=> Rails 3.0.7 application starting in development on
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-05-09 00:49:26] INFO  WEBrick 1.3.1
[2011-05-09 00:49:26] INFO  ruby 1.9.2 (2011-02-18) [i386-solaris2.10]
[2011-05-09 00:49:26] INFO  WEBrick::HTTPServer#start: pid=20066 port=3000

Now we finally go to the address from the browser bar http://<your_ip/domain>:3000/ and we can see your app running.