Installing SQLite, Lighttpd, FastCGI and Ruby bindings on Mac OS X
I’ve had a hard time installing SQLite, Lighttpd, FastCGI together with Ruby bindings on OS X, so I thought I could share my experiences. Maybe someone has similar problems and finds some hints for solving them:
DarwinPorts
I used DarwinPorts to install the software, don’t forget to include the target directories to your path.
For example I install the packages to /opt/local, so I’ve included /opt/local/bin and /opt/local/sbin to may path.
Example .profile:
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
SQLite and Ruby
That was the hard part since my Ruby installation was not properly installed. The best way to install it is to remove ruby and it’s dependencies first:
port -uf uninstall ruby
After that install SWIG, Ruby and Ruby Gems in that order:
port install swig
port install ruby
port install rb-rubygems
Mac OS X Tiger has SQLite3 pre-installed, if you choose to use SQLite 2 you have to install it from DarwinPorts:
port install sqlite
Now we’re ready to install the Ruby bindings for SQLite:
gem install sqlite3-ruby
or for SQLite 2:
gem install sqlite-ruby
My problem was that I had to remove Ruby, install swig and reinstall Ruby. If swig isn’t installed gem can’t compile the native bindings for Ruby and you’ll get something like:
sudo gem install sqlite
Attempting local installation of 'sqlite'
Local gem file not found: sqlite*.gem
Attempting remote installation of 'sqlite'
Building native extensions. This could take a while...
ERROR: While executing gem ... (RuntimeError)
ERROR: Failed to build gem native extension.
Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/sqlite-2.0.1 for inspection.
ruby extconf.rb install sqlite
checking for main() in -lsqlite... no
checking for sqlite.h... no
Lighttpd and FastCGI
Now we’re ready to install Lighttpd and FastCGI:
port install fcgi
port install pcre
port install lighttpd
gem install fcgi
Now what?
Now you’ve got a good starting point for other tutorials like:
- How to use ActiveRecord outside Rails
- A Quick Guide to SQLite and Ruby
- or simply start working with Web.py, Ruby on Rails, Turbo Gears or Django
I find that a great part of the information I have was acquired by looking up something and finding something else on the way.
— Franklin P. Adams