ruby, gems, railsをCentOS 5.4でインストール
OSデフォルトのrpmをインストールする
ruby-1.8.5-5.el5_3.7.i386.rpm ruby-devel-1.8.5-5.el5_3.7.i386.rpm ruby-docs-1.8.5-5.el5_3.7.i386.rpm ruby-irb-1.8.5-5.el5_3.7.i386.rpm ruby-libs-1.8.5-5.el5_3.7.i386.rpm ruby-mode-1.8.5-5.el5_3.7.i386.rpm(emacs関連だからいらない) ruby-rdoc-1.8.5-5.el5_3.7.i386.rpm ruby-ri-1.8.5-5.el5_3.7.i386.rpm ruby-tcltk-1.8.5-5.el5_3.7.i386.rpm(tcl-tk関連だからいらない)
これらをインストールする。
[root@localhost rpms]# rpm -ivh ruby-1.8.5-5.el5_3.7.i386.rpm ruby-devel-1.8.5-5.el5_3.7.i386.rpm ruby-docs-1.8.5-5.el5_3.7.i386.rpm ruby-irb-1.8.5-5.el5_3.7.i386.rpm ruby-libs-1.8.5-5.el5_3.7.i386.rpm ruby-rdoc-1.8.5-5.el5_3.7.i386.rpm ruby-ri-1.8.5-5.el5_3.7.i386.rpm
gemsのインストール
http://d.hatena.ne.jp/unau/20100811/1281488702
ここを見ると、バージョン1.3.5のrubygemsがruby-1.8.5に対応しているようだ。
http://rubyforge.org/frs/?group_id=126
ここからrubygems-1.3.5.tgzをダウンロードしてサーバに置く。
インストールするコマンド
[root@localhost rubygems-1.3.5]# ruby setup.rb
http://ref.layer8.sh/ja/entry/show/id/655
gemのコマンド一覧はこんな感じ。
railsのインストール
[root@localhost rubygems-1.3.5]# gem install rails ERROR: Error installing rails: rake requires Ruby version >= 1.8.6
ruby-1.8.5だと古いらしい…1.8.6以上を求められる。
ruby-1.8系の最新をインストール
CentOS 5.4のデフォルトyumでは、1.8.6に更新できないため、
http://www.ruby-lang.org/ja/downloads/
ここから、1.8系の最新をダウンロードしてくる。
まずはconfigureしてMakefileを作って、makeする。
[root@localhost ruby-1.8.7-p352]# chmod 775 configure [root@localhost ruby-1.8.7-p352]# ./configure --prefix=/usr [root@localhost ruby-1.8.7-p352]# make
rpmパッケージを作るため、checkinstallをインストール
[root@localhost rpms]# yum install checkinstall Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: ftp.iij.ad.jp * extras: ftp.iij.ad.jp * updates: ftp.iij.ad.jp Setting up Install Process No package checkinstall available. Nothing to do
checkinstallがないらしい。
wgetでダウンロードする。
[root@localhost rpms]# wget http://pkgs.repoforge.org/checkinstall/checkinstall-1.6.0-3.el5.rf.i386.rpm
インストールする。
[root@localhost rpms]# rpm -ivh checkinstall-1.6.0-3.el5.rf.i386.rpm
rpmパッケージを作成。
[root@localhost ruby-1.8.7-p352]# checkinstall --fstrans=no checkinstall 1.6.0, Copyright 2002 Felipe Eduardo Sanchez Diaz Duran This software is released under the GNU GPL. The package documentation directory ./doc-pak does not exist. Should I create a default set of package docs? [y]: y Preparing package documentation...OK Please choose the packaging method you want to use. Slackware [S], RPM [R] or Debian [D]? R Please write a description for the package. End your description with an empty line or EOF. >> ************************************** **** RPM package creation selected *** ************************************** This package will be built according to these values: 1 - Summary: [ Package created with checkinstall 1.6.0 ] 2 - Name: [ ruby-1.8.7 ] 3 - Version: [ p352 ] 4 - Release: [ 1 ] 5 - License: [ GPL ] 6 - Group: [ Applications/System ] 7 - Architecture: [ i386 ] 8 - Source location: [ ruby-1.8.7-p352 ] 9 - Alternate source location: [ ] 10 - Requires: [ ] 11 - Provides: [ ruby-1.8.7 ] Enter a number to change any of them or press ENTER to continue: Installing with make install... ========================= Installation results =========================== ./miniruby -I./lib -I.ext/common -I./- -r./ext/purelib.rb ./instruby.rb --make="make" --dest-dir="" --extout=".ext" --mflags="" --make-flags="" --data-mode=0644 --prog-mode=0755 --installed-list .installed.list --mantype="doc" installing binary commands installing command scripts installing library scripts installing headers installing manpages installing extension objects installing extension scripts ======================== Installation successful ========================== Copying documentation directory... ./ ./doc/ ./doc/forwardable.rd ./doc/shell.rd.ja ./doc/NEWS-1.8.0 ./doc/forwardable.rd.ja ./doc/shell.rd ./doc/irb/ ./doc/irb/irb-tools.rd.ja ./doc/irb/irb.rd.ja ./doc/irb/irb.rd ./doc/ChangeLog-1.8.0 ./README.EXT.ja ./README.EXT ./README ./COPYING ./NEWS ./README.ja ./ChangeLog ./GPL ./COPYING.ja Some of the files created by the installation are inside the build directory: /home/sai/ruby-1.8.7-p352 You probably don't want them to be included in the package, especially if they are inside your home directory. Do you want me to list them? [n]: Should I exclude them from the package? (Saying yes is a good idea) [y]: y Building RPM package...OK NOTE: The package will not be installed Erasing temporary files...OK Deleting doc-pak directory...OK Writing backup package... Deleting temp dir...OK ********************************************************************** Done. The new package has been saved to /usr/src/redhat/RPMS/i386/ruby-1.8.7-p352-1.i386.rpm You can install it in your system anytime using: rpm -i ruby-1.8.7-p352-1.i386.rpm **********************************************************************
/usr/src/redhat/RPMS/i386にrpmパッケージが作成されたので、これをインストール。
[root@localhost ruby-1.8.7-p352]# cd /usr/src/redhat/RPMS/i386/
その前に、先にインストールしたruby-1.8.5をアンインストールする。
[root@localhost i386]# rpm -qa '*ruby*' ruby-1.8.5-19.el5_6.1 ruby-devel-1.8.5-19.el5_6.1 ruby-docs-1.8.5-5.el5_3.7 ruby-libs-1.8.5-19.el5_6.1 ruby-irb-1.8.5-19.el5_6.1 ruby-ri-1.8.5-19.el5_6.1 ruby-rdoc-1.8.5-19.el5_6.1 [root@localhost i386]# rpm -evv ruby-1.8.5-19.el5_6.1 ruby-devel-1.8.5-19.el5_6.1 ruby-docs-1.8.5-5.el5_3.7 ruby-libs-1.8.5-19.el5_6.1 ruby-irb-1.8.5-19.el5_6.1 ruby-ri-1.8.5-19.el5_6.1 ruby-rdoc-1.8.5-19.el5_6.1
ruby-1.8.7をインストール。
[root@localhost i386]# rpm -ivh ruby-1.8.7-p352-1.i386.rpm
gemsをrpm作成してからインストール
先ほどインストールしたgemsを退避。
[root@localhost ~]# mv /usr/bin/gem /tmp/gem_BAK
で、インストールに失敗します。
[root@localhost rubygems-1.3.5]# checkinstall -R "ruby setup.rb" checkinstall 1.6.0, Copyright 2002 Felipe Eduardo Sanchez Diaz Duran This software is released under the GNU GPL. The package documentation directory ./doc-pak does not exist. Should I create a default set of package docs? [y]: y Preparing package documentation...OK Please write a description for the package. End your description with an empty line or EOF. >> ************************************** **** RPM package creation selected *** ************************************** This package will be built according to these values: 1 - Summary: [ Package created with checkinstall 1.6.0 ] 2 - Name: [ rubygems ] 3 - Version: [ 1.3.5 ] 4 - Release: [ 1 ] 5 - License: [ GPL ] 6 - Group: [ Applications/System ] 7 - Architecture: [ i386 ] 8 - Source location: [ rubygems-1.3.5 ] 9 - Alternate source location: [ ] 10 - Requires: [ ] 11 - Provides: [ rubygems ] Enter a number to change any of them or press ENTER to continue: Installing with ruby setup.rb... ========================= Installation results =========================== /usr/lib/ruby/1.8/yaml.rb:10:in `require': no such file to load -- yaml/error (LoadError) from /usr/lib/ruby/1.8/yaml.rb:10 from ./lib/rubygems/config_file.rb:7:in `require' from ./lib/rubygems/config_file.rb:7 from ./lib/rubygems.rb:1124:in `require' from ./lib/rubygems.rb:1124 from setup.rb:24:in `require' from setup.rb:24 **** Installation failed. Aborting package creation. Cleaning up...OK Bye.
別のソースのruby-1.8.7をインストール
先ほどインストールしたruby-1.8.7を退避。
[root@localhost ~]# /usr/lib/ruby /tmp/ruby_BAK
この手順が重要。
/usr/lib/rubyが残ったままだと、別のソースのrubyをビルドするときに/usr/lib/rubyが影響してしまうため。
別のソースのruby-1.8.7をダウンロードしてmake、rpmを作成。
[root@localhost sai]# wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7.tar.gz [root@localhost sai]# tar zxvf ruby-1.8.7.tar.gz [root@localhost sai]# cd ruby-1.8.7 [root@localhost ruby-1.8.7]# ./configure --prefix=/usr [root@localhost ruby-1.8.7]# make [root@localhost ruby-1.8.7]# checkinstall --fstrans=no
[root@localhost i386]# rpm -evv ruby-1.8.7-p352-1 [root@localhost i386]# rpm -ivh ruby-1.8.7-1.i386.rpm
もう一度gemsのrpmを作成してインストール
gems-1.3.5だとこの後のrailsインストールでJSONまわりで、エラーとなったため、gems-1.4.2で。
穢れたgemsではダメ。
それgemsちゃうで。ソウルジェムや。
[root@localhost rubygems-1.4.2]# checkinstall -R "ruby setup.rb" checkinstall 1.6.0, Copyright 2002 Felipe Eduardo Sanchez Diaz Duran This software is released under the GNU GPL. ************************************** **** RPM package creation selected *** ************************************** This package will be built according to these values: 1 - Summary: [ Package created with checkinstall 1.6.0 ] 2 - Name: [ rubygems ] 3 - Version: [ 1.4.2 ] 4 - Release: [ 1 ] 5 - License: [ GPL ] 6 - Group: [ Applications/System ] 7 - Architecture: [ i386 ] 8 - Source location: [ rubygems-1.4.2 ] 9 - Alternate source location: [ ] 10 - Requires: [ ] 11 - Provides: [ rubygems ] Enter a number to change any of them or press ENTER to continue: Installing with ruby setup.rb... ========================= Installation results =========================== RubyGems 1.4.2 installed === 1.4.2 / 2011-01-06 Bug fixes: * Gem::Versions: "1.b1" != "1.b.1", but "1.b1" eql? "1.b.1". Fixes gem indexing. * Fixed Gem.find_files. * Removed otherwise unused #find_all_dot_rb. Only 6 days old and hella buggy.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
gemsのrpmが無事できたので、これをインストール。
[root@localhost rubygems-1.4.2]# cd /usr/src/redhat/RPMS/i386/ [root@localhost i386]# rpm -ivh rubygems-1.4.2-1.i386.rpm
インストールできたか確認。
[root@localhost i386]# rpm -qa '*ruby*' ruby-1.8.7-1 rubygems-1.4.2-1
railsをインストール
gems-1.3.5を先に試した時は、multi_json-1.0.4でエラーとなったため、gems-1.4.2で。
[root@localhost i386]# gem install rails -y INFO: `gem install -y` is now default and will be removed INFO: use --ignore-dependencies to install only the gems you list Fetching: activesupport-3.2.1.gem (100%) Fetching: builder-3.0.0.gem (100%) Fetching: activemodel-3.2.1.gem (100%) Fetching: rack-1.4.1.gem (100%) Fetching: rack-cache-1.1.gem (100%) Fetching: rack-test-0.6.1.gem (100%) Fetching: journey-1.0.1.gem (100%) Fetching: hike-1.2.1.gem (100%) Fetching: tilt-1.3.3.gem (100%) Fetching: sprockets-2.1.2.gem (100%) Fetching: erubis-2.7.0.gem (100%) Fetching: actionpack-3.2.1.gem (100%) Fetching: arel-3.0.0.gem (100%) Fetching: tzinfo-0.3.31.gem (100%) Fetching: activerecord-3.2.1.gem (100%) Fetching: activeresource-3.2.1.gem (100%) Fetching: mime-types-1.17.2.gem (100%) Fetching: polyglot-0.3.3.gem (100%) Fetching: treetop-1.4.10.gem (100%) Fetching: mail-2.4.1.gem (100%) Fetching: actionmailer-3.2.1.gem (100%) Fetching: thor-0.14.6.gem (100%) Fetching: rack-ssl-1.3.2.gem (100%) Fetching: railties-3.2.1.gem (100%) Fetching: bundler-1.0.21.gem (100%) Fetching: rails-3.2.1.gem (100%) Successfully installed multi_json-1.0.4 Successfully installed activesupport-3.2.1 Successfully installed builder-3.0.0 Successfully installed activemodel-3.2.1 Successfully installed rack-1.4.1 Successfully installed rack-cache-1.1 Successfully installed rack-test-0.6.1 Successfully installed journey-1.0.1 Successfully installed hike-1.2.1 Successfully installed tilt-1.3.3 Successfully installed sprockets-2.1.2 Successfully installed erubis-2.7.0 Successfully installed actionpack-3.2.1 Successfully installed arel-3.0.0 Successfully installed tzinfo-0.3.31 Successfully installed activerecord-3.2.1 Successfully installed activeresource-3.2.1 Successfully installed mime-types-1.17.2 Successfully installed polyglot-0.3.3 Successfully installed treetop-1.4.10 Successfully installed mail-2.4.1 Successfully installed actionmailer-3.2.1 Successfully installed thor-0.14.6 Successfully installed rack-ssl-1.3.2 Successfully installed railties-3.2.1 Successfully installed bundler-1.0.21 Successfully installed rails-3.2.1 27 gems installed Installing ri documentation for multi_json-1.0.4... Installing ri documentation for activesupport-3.2.1... Installing ri documentation for builder-3.0.0... Installing ri documentation for activemodel-3.2.1... Installing ri documentation for rack-1.4.1... Installing ri documentation for rack-cache-1.1... Installing ri documentation for rack-test-0.6.1... Installing ri documentation for journey-1.0.1... Installing ri documentation for hike-1.2.1... Installing ri documentation for tilt-1.3.3... Installing ri documentation for sprockets-2.1.2... Installing ri documentation for erubis-2.7.0... Installing ri documentation for actionpack-3.2.1... Installing ri documentation for arel-3.0.0... Installing ri documentation for tzinfo-0.3.31... Installing ri documentation for activerecord-3.2.1... Installing ri documentation for activeresource-3.2.1... Installing ri documentation for mime-types-1.17.2... Installing ri documentation for polyglot-0.3.3... Installing ri documentation for treetop-1.4.10... Installing ri documentation for mail-2.4.1... Installing ri documentation for actionmailer-3.2.1... Installing ri documentation for thor-0.14.6... Installing ri documentation for rack-ssl-1.3.2... Installing ri documentation for railties-3.2.1... Installing ri documentation for bundler-1.0.21... Installing ri documentation for rails-3.2.1... Installing RDoc documentation for multi_json-1.0.4... Installing RDoc documentation for activesupport-3.2.1... Installing RDoc documentation for builder-3.0.0... Installing RDoc documentation for activemodel-3.2.1... Installing RDoc documentation for rack-1.4.1... Installing RDoc documentation for rack-cache-1.1... Installing RDoc documentation for rack-test-0.6.1... Installing RDoc documentation for journey-1.0.1... Installing RDoc documentation for hike-1.2.1... Installing RDoc documentation for tilt-1.3.3... Installing RDoc documentation for sprockets-2.1.2... Installing RDoc documentation for erubis-2.7.0... Installing RDoc documentation for actionpack-3.2.1... Installing RDoc documentation for arel-3.0.0... Installing RDoc documentation for tzinfo-0.3.31... Installing RDoc documentation for activerecord-3.2.1... Installing RDoc documentation for activeresource-3.2.1... Installing RDoc documentation for mime-types-1.17.2... Installing RDoc documentation for polyglot-0.3.3... Installing RDoc documentation for treetop-1.4.10... Installing RDoc documentation for mail-2.4.1... Installing RDoc documentation for actionmailer-3.2.1... Installing RDoc documentation for thor-0.14.6... Installing RDoc documentation for rack-ssl-1.3.2... Installing RDoc documentation for railties-3.2.1... Installing RDoc documentation for bundler-1.0.21... Installing RDoc documentation for rails-3.2.1...
mysql接続用モジュールをインストール
mysql-develのパッケージがインストールされていない場合は、エラーとなるようです。
ウチのサーバはphpまわりでmysqlの環境を作っているので、一発でインストールできました。
[root@localhost i386]# gem install --remote mysql Fetching: mysql-2.8.1.gem (100%) Building native extensions. This could take a while... Successfully installed mysql-2.8.1 1 gem installed Installing ri documentation for mysql-2.8.1... Installing RDoc documentation for mysql-2.8.1...