Capistrano series - installing Ruby, Nginx and sqlite3.

Continuing with setting up the Slice, we need to install Ruby, rubygems and Nginx.

We'll install Ruby via aptitude and then install rubygems from source (as that will give us the latest version).

Once done, we can go ahead and install Nginx, a lightweight web server, via aptitude.


Ruby and rubygems

Installing Ruby via aptitude will give us the latest version (as of writing this article) and is a nice and easy way to ensure that if there are any security patches, they can be easily installed.

Rubygems will be installed via source code as the packaged version is 0.9.4 and the latest version is 1.0.1. It is highly recommended you use the latest version and so take the time to install via source.

A full run down of installing Ruby and rubygems is shown here

Note the article does include installing and configuring MySQL. You are, of course, free to skip that section as we will be using sqlite3 for this Capistrano series.

Once done, you should have the following Ruby version installed on your Slice:

ruby -v

ruby 1.8.6 (2007-06-07 patchlevel 36) [x86_64-linux]

and rubygems should output this:

gem -v

1.0.1

Excellent. Now we can move onto installing Nginx.

Nginx

You can use any web server that is capable of proxying to a mongrel cluster such as Apache 2.2+, etc but I have chosen Nginx as it is a light weight server that is ample for our needs.

Future articles will look at the Litepseed web server so we don't have to proxy to another server, etc and so avoid all the clumsy requests and configurations.

However, for the moment, Nginx with mongrels will more than suffice and will give us a solid base to work from.

Nginx installation

This is pretty easy to do as the package manager (aptitude) has Nginx.

To install:

sudo aptitude install nginx

Er, that's it.

Pretty simple. For more information, check out installing Nginx via aptitude.

sqlite3

One of the final packages to install onto the Slice is the database and associated libs.

In this application we're using sqlite3 as the db. You can, of course, use MySQL, postgres or any of the supported db's but for simplicity we're going to use sqlite3.

All we need to do is this:

sudo aptitude install sqlite3 libsqlite3-ruby

That's it for the database but do ensure you have the required packages and libs installed on your local workstation (how you do this will depend on what OS and distro you are using on your workstation and is beyond these articles).

Done

By now, you will see the complete setup starting to take shape - we have installed and secured the Slice and subversion is up and running.

Now we can add to that list as Ruby, rubygems, Nginx and sqlite3 are installed.

The next article will look at installing Rails and creating a test vhost for Nginx.

Once that is done, we'll move onto Capistrano and deploying our application.

PickledOnion.

Article Comments:

Brandon commented Thu Apr 24 18:15:59 UTC 2008:

Don't we need to install the sqlite3-ruby gem as well?

When I try that, it fails:

$ sudo gem install sqlite3-ruby
[sudo] password for brandon:
Updating metadata for 15 gems from http://gems.rubyforge.org/
...............
complete
Building native extensions.  This could take a while...
ERROR:  Error installing sqlite3-ruby:
        ERROR: Failed to build gem native extension.

/usr/bin/ruby1.8 extconf.rb install sqlite3-ruby checking for sqlite3.h... no

make make: * No rule to make target ruby.h', needed bysqlite3apiwrap.o'. Stop.

Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1 for inspection. Results logged to /usr/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/ext/sqlite3api/gemmake.out

Jorgen Johnson commented Thu Jun 05 03:25:25 UTC 2008:

For Brandon and others who ran into the same issue as Brandon. I was running into the same issue installing sqlite3-ruby gem on an Ubunut Hardy slice. Installing libsqlite3-dev seems to have solved the issue for me:

sudo aptitude install libsqlite3-dev
sudo gem install sqlite3-ruby
Want to comment?


(not made public)

(optional)

(use plain text or Markdown syntax)