CentOS5.7にRubyを入れる
libyaml-develが必要らしいので入れる。
CentOS標準レポジトリにはないのでEPELから入れる。
# cd /usr/local/src # wget http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm # rpm -Uvh epel-release-5-4.noarch.rpm # yum --enablerepo=epel install libyaml-devel.x86_64
SQLiteが必要らしいので入れる。
yumで入るバージョンが古いので、ソースから入れる。
# cd /usr/local/src # wget http://www.sqlite.org/sqlite-autoconf-3070400.tar.gz # tar zxvf sqlite-autoconf-3070400.tar.gz # cd sqlite-autoconf-3070400 # ./configure # make # make install
そして、Rubyを入れる。
# cd /usr/local/src/ # wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p0.tar.gz # tar zxvf ruby-1.9.3-p0.tar.gz # cd ruby-1.9.3-p0 # ./configure --prefix=/usr # make # make install # ruby -v ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux] # gem -v 1.8.11
ついでにrailsも入れよう。
# gem install rails
と思ったら、以下のようなエラーが出たので
ERROR: Loading command: install (LoadError) cannot load such file -- zlib ERROR: While executing gem ... (NameError) uninitialized constant Gem::Commands::InstallCommand
zlibを入れてあげる。
# cd /usr/local/src/ruby-1.9.3-p0/ext/zlib # ruby extconf.rb # make # make install
再度railsを入れる。
# gem install rails file 'lib' not found # rails -v Rails 3.2.0
インストールは出来たけど、何かエラー出たので、以下のようにした。
# gem install rails --no-ri --no-rdoc Successfully installed rails-3.2.0 1 gem installed # gem install rails Fetching: rails-3.2.0.gem (100%) Successfully installed rails-3.2.0 1 gem installed Installing ri documentation for rails-3.2.0... Installing RDoc documentation for rails-3.2.0...
とりあえず、大丈夫かな。
新規アプリケーションを作ろうとしたら、エラーが出たので、必要なものを適宜入れる。
# rails new hoge /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- openssl (LoadError) # yum install openssl-devel.x86_64 # cd /usr/local/src/ruby-1.9.3-p0/ext/openssl/ # ruby extconf.rb # make # make install
サーバ起動しようとしたら、エラー出たので対応する。
undefined symbol: sqlite3_initialize # gem install sqlite3 # vi ~/.bashrc LD_LIBRARY_PATH=/usr/local/lib export LD_LIBRARY_PATH # source ~/.bashrc
またまた何かエラー出たので対応する。
Could not find a JavaScript runtime. # vi Gemfile gem 'execjs' gem 'therubyracer' # gem install therubyracer # bundle install
とりあえず、サーバ起動出来た。。。
# rails s => Booting WEBrick => Rails 3.2.0 application starting in development on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server [2012-01-23 00:34:20] INFO WEBrick 1.3.1 [2012-01-23 00:34:20] INFO ruby 1.9.3 (2011-10-30) [x86_64-linux] [2012-01-23 00:34:20] INFO WEBrick::HTTPServer#start: pid=11548 port=3000
apacheと連携させるためにPassengerを入れる。
# gem install passenger # passenger-install-apache2-module
不足しているものが表示されるので、適宜入れていく。
自分の場合は以下を入れました。
# yum install httpd-devel.x86_64 # yum install curl-devel.x86_64
apacheの設定ファイルに追加
LoadModule passenger_module /usr/lib/ruby/gems/1.9.1/gems/passenger-3.0.11/ext/apache2/mod_passenger.so PassengerRoot /usr/lib/ruby/gems/1.9.1/gems/passenger-3.0.11 PassengerRuby /usr/bin/ruby <VirtualHost *:80> ServerName www.yourhost.com DocumentRoot /somewhere/public # <-- be sure to point to 'public'! <Directory /somewhere/public> AllowOverride all # <-- relax Apache security settings Options -MultiViews # <-- MultiViews must be turned off </Directory> </VirtualHost>
PATHを設定します。
# vi /etc/sysconfig/httpd LD_LIBRARY_PATH=/usr/local/lib export LD_LIBRARY_PATH
うーん。
まだエラーが出ているんですが、後日時間を見つけてエラーをつぶしていこうと思います。
前回やったときは、もっとスムーズにいった気がするんですがね。。。