sqlite3-rubyのインストール

(同じ日にエントリを上げてしまってコメント欄が被っていたので分離しました)
unix及びrubyでwebアプリ開発のお勉強中に躓いたのでメモ。

sqlite3-rubyをインストールするにはsqlite-develのインストールが必要だが、その方法を見るとどのサイトも

yum install sqlite-devel

と書いてあり、sudo権限がない場合や、ローカルにインストールしたい場合などにこれではインストール出来ず、必然的にsqlite3-rubyもインストールできない。

これを解決するため、まずはsqliteを手動でローカルにインストールする。

$ mkdir sqlite
$ cd sqlite
$ wget http://www.sqlite.org/sqlite-amalgamation-3.6.23.1.tar.gz
$ tar vxzf sqlite-amalgamation-3.6.23.1.tar.gz
$ cd sqlite-3.6.23.1
$ ./configure --prefix=$HOME

後に

$ make

して

$ make install

でインストール。

ようやく本題のsqlite3-rubyのインストールに入れるが、普通にインストールすると

$ gem install sqlite3-ruby
Building native extensions.  This could take a while...
ERROR:  Error installing sqlite3-ruby:
        ERROR: Failed to build gem native extension.

/home/atago/.rvm/rubies/ruby-head/bin/ruby extconf.rb
checking for sqlite3.h... no
sqlite3.h is missing. Try 'port install sqlite3 +universal' or 'yum install sqlite3-devel'
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=/home/atago/.rvm/rubies/ruby-head/bin/ruby
        --with-sqlite3-dir
        --without-sqlite3-dir
        --with-sqlite3-include
        --without-sqlite3-include=${sqlite3-dir}/include
        --with-sqlite3-lib
        --without-sqlite3-lib=${sqlite3-dir}/lib


Gem files will remain installed in /home/atago/.rvm/gems/ruby-head/gems/sqlite3-ruby-1.3.0 for inspection.
Results logged to /home/atago/.rvm/gems/ruby-head/gems/sqlite3-ruby-1.3.0/ext/sqlite3/gem_make.out

とエラーを吐く。
sqlite-develをyumコマンドでなく、手作業でローカルにインストールしたため、パスを明示的にしてやらないといけないので、エラーに書かれているよう、オプションを指定して実行してあげる。

$ gem install sqlite3-ruby -- --with-sqlite3-dir=$HOME

これでようやくsqlite3-rubyをインストールできた。