さくらVPS環境で、ruby-1.9.2-p0とRails3をインストールする。その後、chef-soloをインストールしてみる。



LinuxにRuby1.9.2とRails3をインストール」を参考にRuby1.9.2とRails3をインストールしました。さくらVPS上で、chef-soloを試しに使ってみたかったので、うまくいくか試してみました。chef-soloに関しては、「chef-soloで作業環境構築の自動化」を参考にしました。
 

ruby-1.9.2をインストールする

ruby1.9のソースをダウンロードし、インストールします。

 $cd /usr/local/src/
 $wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p0.tar.gz
 $tar zxvf ruby-1.9.2-p0.tar.gz
 $cd ruby-1.9.2-p0
 $./configure
 $make 
 $make install
  installing binary commands:   /usr/local/bin
  installing base libraries:    /usr/local/lib
  installing arch files:        /usr/local/lib/ruby/1.9.1/x86_64-linux
  installing extension objects: /usr/local/lib/ruby/1.9.1/x86_64-linux
  installing extension objects: /usr/local/lib/ruby/site_ruby/1.9.1/x86_64-linux
  installing extension objects: /usr/local/lib/ruby/vendor_ruby/1.9.1/x86_64-linux
  installing extension headers: /usr/local/include/ruby-1.9.1/x86_64-linux
  installing extension scripts: /usr/local/lib/ruby/1.9.1
  installing extension scripts: /usr/local/lib/ruby/site_ruby/1.9.1
  installing extension scripts: /usr/local/lib/ruby/vendor_ruby/1.9.1
  installing extension headers: /usr/local/include/ruby-1.9.1/ruby
  installing rdoc:              /usr/local/share/ri/1.9.1/system
  installing capi-docs:         /usr/local/share/doc/ruby
  installing command scripts:   /usr/local/bin
  installing library scripts:   /usr/local/lib/ruby/1.9.1
  installing common headers:    /usr/local/include/ruby-1.9.1
  installing manpages:          /usr/local/share/man/man1
  installing default gems:      /usr/local/lib/ruby/gems/1.9.1 (cache, doc, gems, specifications)
                              rake 0.8.7
                              rdoc 2.5.8
                              minitest 1.6.0

 
インストールしたものが動くかどうか試してみました。

 gem list
 
 *** LOCAL GEMS ***
 
 minitest (1.6.0)
 rake (0.8.7)
 rdoc (2.5.8)

 

sqlite3-rubyをインストールする

sqlite3をgemからインストールします。

 gem i sqlite3-ruby

 
参考にしたページと同じところでsqliteのインストールがエラーとなりました。
rpm管理下の方がなにかと都合が良いので、checkinstallを利用してみます。

 $cd /usr/local/src/
 $wget http://asic-linux.com.mx/~izto/checkinstall/files/source/checkinstall-1.6.2.tar.gz
 $tar zxvf checkinstall-1.6.2.tar.gz
 $cd checkinstall-1.6.2.tar.gz
 $make install
 
  $pwd
  /usr/local/src/checkinstall-1.6.2
  $/usr/local/sbin/checkinstall
  $/usr/src/redhat/RPMS/x86_64
  $rpm -i checkinstall-1.6.2-1.x86_64.rpm

 
きちんとインストールされているか確認をしてみます。

 $yum list checkinstall
   Installed Packages
   checkinstall.x86_64                                                                      1.6.2-1                                        installed                            

 
sqlite3をビルドしてrpmにしてインストールしてみます。sqlite3インストール後、そのままrailsをインストールします。

 $cd /usr/local/src/
 $wget http://www.sqlite.org/sqlite-amalgamation-3.7.2.tar.gz
 $tar zxvf sqlite-amalgamation-3.7.2.tar.gz
 $cd sqlite-3.7.2
 $./configure
 
 $/usr/local/sbin/checkinstall
 $cd /usr/src/redhat/RPMS/x86_64/
 $rpm -i sqlite-3.7.2-1.x86_64.rpm
 
 $gem i sqlite3-ruby
 
 $gem i rails

 

動作確認をしてみる

railsコマンドで新しいプロジェクトを作成します。blogというディレクトリが作成されます。

 rails new blog
 
 rails c 
 /usr/local/lib/ruby/1.9.1/irb/completion.rb:9:in `require': no such file to load -- readline (LoadError)

 
rails c」を試してみると、エラーがでました。「readline」が足りないみたいです。

 $yum install readline-devel
 $cd /usr/local/src/ruby-1.9.2-p0/ext/readline
 $ruby extconf.rb
  $make
  $make install
  $ruby -r readline -e ""
 #エラーがでてない。

 
WEBrickサーバを実行してみます。rails new blogを実行したディレクトリまで移動し、「rails s -p 3001」を実行します。

 netstat -anp | grep 3000
 tcp        0      0 0.0.0.0:3000                0.0.0.0:*                   LISTEN      766/java
 rails s -p 3001

 
iptablesなどの任意の設定をし、ブラウザからアクセスできることを確認しました。

 http://ipaddress:3001/

 

chef-soloをインストールする

chef-soloで作業環境構築の自動化」を参考にし、gemからインストールを
行います。

 gem install chef --no-rdoc --no-ri
 Building native extensions.  This could take a while...
 Successfully installed mixlib-config-1.1.2
 Successfully installed mixlib-cli-1.2.0
 Successfully installed mixlib-log-1.3.0
 Successfully installed mixlib-authentication-1.1.4
 Successfully installed json-1.4.6
 Successfully installed extlib-0.9.15
 Successfully installed systemu-1.2.0
 Successfully installed ohai-0.5.8
 Successfully installed rest-client-1.6.1
 Successfully installed bunny-0.6.0
 Successfully installed moneta-0.6.0
 Successfully installed highline-1.6.1
 Successfully installed uuidtools-2.1.2
 Successfully installed chef-0.9.14
 14 gems installed

 
とりあえず、よく分からないので「Chefリポジトリのひな形をGitHubからいただいて来て設定ファイルを作る。」を
そのまま実行してみます。

 $ git clone git://github.com/opscode/chef-repo.git
 $ cd chef-repo
 $ mkdir .chef

  .chef/solo.rb
    file_cache_path "/tmp/chef-solo"
    cookbook_path "/home/akahige/chef-repo/cookbooks"
  .chef/chef.json
    {
     "run_list": [ "recipe[base_packages]" ]
    }

 
chef-soloを実行してみます。

 $chef-solo -c .chef/solo.rb -j .chef/chef.json
  <internal:lib/rubygems/custom_require>:29:in `require': /usr/local/lib/ruby/site_ruby/1.9.1/x86_64-linux/openssl.so: undefined symbol: d2i_ECPKParameters -  
   /usr/local/lib/ruby/site_ruby/1.9.1/x86_64-linux/openssl.so (LoadError)

 
いろいろ試してみたが、openssl.soのエラーがとれなかったので、引き続き課題にできればと思います。
ruby1.8.7 もインストールされており、その影響があるかもしれないので、もう一度、きれいな環境を作ってみたいと思います。)