CentOS5.6のインストールが無事に終了しましたので(イロイロ設定があるのはわかるのですが、とりあえず放置…)RubyやらRailsやらのインストールを行いたいと思います。
なお、参考にしたサイトはこちらです。
CentOS 5.5 に Ruby 1.9.2 をRPMでインストール - 手順書.com
Rubyのインストール
Rubyのインストールはtar.gzファイルをダウンロードしてmakeしてインストールという流れもありますが、今回はrpmオパッケージを作成してインストールを行いタイト思います。rpmパッケージを利用する方がアンインストールが簡単なので、、、
1.checkinstallの取得とインストール
checkinstallはどうやらtarからrpmファイルを生成してくれるツールのようです。 TAR から RPM を生成できる CheckInstall
[sourcecode language="bash"] wget http://packages.sw.be/checkinstall/checkinstall-1.6.0-3.el4.rf.x86_64.rpm … apt.sw.be をDNSに問いあわせています... 193.1.193.67 apt.sw.be|193.1.193.67|:80 に接続しています... 接続しました。 HTTP による接続要求を送信しました、応答を待っています... 200 OK 長さ: 84384 (82K) [application/x-redhat-package-manager] `checkinstall-1.6.0-3.el4.rf.x86_64.rpm' に保存中
100%[======================================>] 84,384 51.0K/s 時間 1.6s
2011-11-06 21:06:10 (51.0 KB/s) - `checkinstall-1.6.0-3.el4.rf.x86_64.rpm' へ保存完了 [84384/84384]
rpm -ivh checkinstall-1.6.0-3.el4.rf.x86_64.rpm
警告: checkinstall-1.6.0-3.el4.rf.x86_64.rpm: ヘッダ V3 DSA signature: NOKEY, key ID 6b8d79e6 準備中... ########################################### [100%] 1:checkinstall ########################################### [100%] [/sourcecode]
2.Rubyをコンパイルするために必要なライブラリをインストールします。
結構いろいろなライブラリが必要になります。とはいうものの、入れ忘れてもmake時にエラーが出てくるのでその内容を確認してインストールすればOKですが…。
[sourcecode language="bash"]
yum install gcc gcc-c++ make zlib perl zlib-devel openssl-devel readline-devel libxml2-devel bzip2-devel unzip libjpeg-devel libpng-devel freetype-devel -y
Loaded plugins: downloadonly, fastestmirror Loading mirror speeds from cached hostfile * base: rsync.atworks.co.jp * extras: rsync.atworks.co.jp * updates: rsync.atworks.co.jp Setting up Install Process Package 1:make-3.81-3.el5.x86_64 already installed and latest version Package 4:perl-5.8.8-32.el5_6.3.x86_64 already installed and latest version Package unzip-5.52-3.el5.x86_64 already installed and latest version Resolving Dependencies --> Running transaction check …
Dependencies Resolved
Package Arch Version Repository Size
Installing: bzip2-devel i386 1.0.3-6.el5_5 base 39 k bzip2-devel x86_64 1.0.3-6.el5_5 base 38 k freetype-devel i386 2.2.1-28.el5_7.1 updates 148 k freetype-devel x86_64 2.2.1-28.el5_7.1 updates 148 k gcc x86_64 4.1.2-51.el5 base 5.3 M gcc-c++ x86_64 4.1.2-51.el5 base 3.8 M libjpeg-devel i386 6b-37 base 105 k libjpeg-devel x86_64 6b-37 base 105 k libpng-devel i386 2:1.2.10-7.1.el5_7.5 updates 182 k libpng-devel x86_64 2:1.2.10-7.1.el5_7.5 updates 185 k libxml2-devel i386 2.6.26-2.1.12.el5_7.1 updates 2.1 M libxml2-devel x86_64 2.6.26-2.1.12.el5_7.1 updates 2.1 M openssl-devel i386 0.9.8e-20.el5 base 1.9 M openssl-devel x86_64 0.9.8e-20.el5 base 1.9 M perl i386 4:5.8.8-32.el5_6.3 extras 12 M readline-devel i386 5.1-3.el5 base 146 k readline-devel x86_64 5.1-3.el5 base 159 k zlib-devel i386 1.2.3-4.el5 base 101 k zlib-devel x86_64 1.2.3-4.el5 base 103 k Installing for dependencies: bzip2-libs i386 1.0.3-6.el5_5 base 37 k cpp x86_64 4.1.2-51.el5 base 2.9 M e2fsprogs-devel x86_64 1.39-33.el5 base 637 k gdbm i386 1.8.0-26.2.1.el5_6.1 base 28 k glibc-devel x86_64 2.5-65 base 2.4 M glibc-headers x86_64 2.5-65 base 594 k kernel-headers x86_64 2.6.18-274.7.1.el5 updates 1.3 M keyutils-libs-devel x86_64 1.2-1.el5 base 27 k krb5-devel x86_64 1.6.1-62.el5 base 1.9 M libselinux-devel x86_64 1.33.4-5.7.el5 base 149 k libsepol-devel x86_64 1.15.2-3.el5 base 192 k libstdc++-devel x86_64 4.1.2-51.el5 base 2.8 M libtermcap-devel x86_64 2.0.8-46.1 base 56 k libxml2 i386 2.6.26-2.1.12.el5_7.1 updates 795 k pkgconfig x86_64 1:0.21-2.el5 base 61 k
Transaction Summary
Install 34 Package(s) Upgrade 0 Package(s)
Total download size: 44 M Downloading Packages: (1/34): keyutils-libs-devel-1.2-1.el5.x86_64.rpm | 27 kB 00:00 (2/34): gdbm-1.8.0-26.2.1.el5_6.1.i386.rpm | 28 kB 00:00
…
Total 6.5 MB/s | 44 MB 00:06 Running rpm_check_debug Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Installing : zlib-devel 1/34 Installing : pkgconfig 2/34 …
Installed: bzip2-devel.i386 0:1.0.3-6.el5_5 bzip2-devel.x86_64 0:1.0.3-6.el5_5 freetype-devel.i386 0:2.2.1-28.el5_7.1 freetype-devel.x86_64 0:2.2.1-28.el5_7.1 gcc.x86_64 0:4.1.2-51.el5 gcc-c++.x86_64 0:4.1.2-51.el5 libjpeg-devel.i386 0:6b-37 libjpeg-devel.x86_64 0:6b-37 libpng-devel.i386 2:1.2.10-7.1.el5_7.5 libpng-devel.x86_64 2:1.2.10-7.1.el5_7.5 libxml2-devel.i386 0:2.6.26-2.1.12.el5_7.1 libxml2-devel.x86_64 0:2.6.26-2.1.12.el5_7.1 openssl-devel.i386 0:0.9.8e-20.el5 openssl-devel.x86_64 0:0.9.8e-20.el5 perl.i386 4:5.8.8-32.el5_6.3 readline-devel.i386 0:5.1-3.el5 readline-devel.x86_64 0:5.1-3.el5 zlib-devel.i386 0:1.2.3-4.el5 zlib-devel.x86_64 0:1.2.3-4.el5
Dependency Installed: bzip2-libs.i386 0:1.0.3-6.el5_5 cpp.x86_64 0:4.1.2-51.el5 e2fsprogs-devel.x86_64 0:1.39-33.el5 gdbm.i386 0:1.8.0-26.2.1.el5_6.1 glibc-devel.x86_64 0:2.5-65 glibc-headers.x86_64 0:2.5-65 kernel-headers.x86_64 0:2.6.18-274.7.1.el5 keyutils-libs-devel.x86_64 0:1.2-1.el5 krb5-devel.x86_64 0:1.6.1-62.el5 libselinux-devel.x86_64 0:1.33.4-5.7.el5 libsepol-devel.x86_64 0:1.15.2-3.el5 libstdc++-devel.x86_64 0:4.1.2-51.el5 libtermcap-devel.x86_64 0:2.0.8-46.1 libxml2.i386 0:2.6.26-2.1.12.el5_7.1 pkgconfig.x86_64 1:0.21-2.el5
Complete! [/sourcecode]
3.rpm-buildをインストールします。
RPMファイルを作成するためには rpm-build が必要になるようなので、インストールします。
[sourcecode language="bash"]
yum install rpm-build
Loaded plugins: downloadonly, fastestmirror Loading mirror speeds from cached hostfile * base: rsync.atworks.co.jp * extras: rsync.atworks.co.jp * updates: rsync.atworks.co.jp Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package rpm-build.x86_64 0:4.4.2.3-22.el5_7.2 set to be updated --> Processing Dependency: elfutils for package: rpm-build --> Running transaction check ---> Package elfutils.x86_64 0:0.137-3.el5 set to be updated --> Processing Dependency: elfutils-libs-x86_64 = 0.137-3.el5 for package: elfutils --> Processing Dependency: libdw.so.1(ELFUTILS_0.130)(64bit) for package: elfutils --> Processing Dependency: libdw.so.1(ELFUTILS_0.127)(64bit) for package: elfutils --> Processing Dependency: libdw.so.1(ELFUTILS_0.126)(64bit) for package: elfutils --> Processing Dependency: libasm.so.1(ELFUTILS_1.0)(64bit) for package: elfutils --> Processing Dependency: libdw.so.1(ELFUTILS_0.122)(64bit) for package: elfutils --> Processing Dependency: libdw.so.1()(64bit) for package: elfutils --> Processing Dependency: libasm.so.1()(64bit) for package: elfutils --> Running transaction check ---> Package elfutils-libs.x86_64 0:0.137-3.el5 set to be updated --> Finished Dependency Resolution
Dependencies Resolved
Package Arch Version Repository Size
Installing: rpm-build x86_64 4.4.2.3-22.el5_7.2 updates 302 k Installing for dependencies: elfutils x86_64 0.137-3.el5 base 215 k elfutils-libs x86_64 0.137-3.el5 base 183 k
Transaction Summary
Install 3 Package(s) Upgrade 0 Package(s)
Total download size: 700 k Is this ok [y/N]: y Downloading Packages: (1/3): elfutils-libs-0.137-3.el5.x86_64.rpm | 183 kB 00:00 (2/3): elfutils-0.137-3.el5.x86_64.rpm | 215 kB 00:00
(3/3): rpm-build-4.4.2.3-22.el5_7.2.x86_64.rpm | 302 kB 00:00
Total 2.0 MB/s | 700 kB 00:00 Running rpm_check_debug Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Installing : elfutils-libs 1/3 Installing : elfutils 2/3 Installing : rpm-build 3/3
Installed: rpm-build.x86_64 0:4.4.2.3-22.el5_7.2
Dependency Installed: elfutils.x86_64 0:0.137-3.el5 elfutils-libs.x86_64 0:0.137-3.el5
Complete! [/sourcecode]
4.Rubyのソースをコンパイルするディレクトリを作成して移動します。
[sourcecode language="bash"]
mkdir /usr/lcoal
mkdir /usr/lcoal/src
cd /usr/lcoal/src
[/sourcecode]
5.Rubyのソースコードの取得とmakeからrpmファイルの作成を行います。
[sourcecode language="bash"]
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p180.tar.gz
--2011-11-06 21:08:28-- ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p180.tar.gz => `ruby-1.9.2-p180.tar.gz' ftp.ruby-lang.org をDNSに問いあわせています... 221.186.184.68 ftp.ruby-lang.org|221.186.184.68|:21 に接続しています... 接続しました。 anonymous としてログインしています... ログインしました! ==> SYST ... 完了しました。 ==> PWD ... 完了しました。 ==> TYPE I ... 完了しました。 ==> CWD /pub/ruby/1.9 ... 完了しました。 ==> SIZE ruby-1.9.2-p180.tar.gz ... 11158935 ==> PASV ... 完了しました。 ==> RETR ruby-1.9.2-p180.tar.gz ... 完了しました。 長さ: 11158935 (11M)
100%[======================================>] 11,158,935 4.71M/s 時間 2.3s
2011-11-06 21:08:30 (4.71 MB/s) - `ruby-1.9.2-p180.tar.gz' へ保存終了 [11158935]
tar xvzf ruby-1.9.2-p180.tar.gz
ruby-1.9.2-p180/ ruby-1.9.2-p180/.cvsignore ruby-1.9.2-p180/.document ruby-1.9.2-p180/.gdbinit ...
./configure
... checking for nroff... /usr/bin/nroff .ext/include/x86_64-linux/ruby/config.h updated ruby library version = 1.9.1 configure: creating ./config.status config.status: creating Makefile
make
gcc -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -I. -I.ext/include/x86_64-linux -I./include -I. -DRUBY_EXPORT -o main.o -c main.c gcc -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -I. -I.ext/include/x86_64-linux -I./include -I. -DRUBY_EXPORT -o dln.o -c dln.c … 100% [515/515] doc/re.rdoc
Generating RI...
Files: 515 Classes: 1087 ( 654 undocumented) Constants: 1364 ( 1141 undocumented) Modules: 239 ( 137 undocumented) Methods: 7642 ( 2876 undocumented) 53.46% documented
Elapsed: 64.3s [/sourcecode]
6.RPMファイルを作成します。
[sourcecode language="bash"]
/usr/sbin/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.9.2 ] 3 - Version: [ p180 ] 4 - Release: [ 1 ] 5 - License: [ GPL ] 6 - Group: [ Applications/System ] 7 - Architecture: [ x86_64 ] 8 - Source location: [ ruby-1.9.2-p180 ] 9 - Alternate source location: [ ] 10 - Requires: [ ] 11 - Provides: [ ruby-1.9.2 ]
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 ./tool/generic_erb.rb -c -o encdb.h ./template/encdb.h.tmpl ./enc enc encdb.h unchanged make -f enc.mk RUBY="./miniruby -I./lib -I.ext/common -I./- -r./ext/purelib.rb " MINIRUBY="./miniruby -I./lib -I.ext/common -I./- -r./ext/purelib.rb " srcs
…
No newer files. ./miniruby -I./lib -I.ext/common -I./- -r./ext/purelib.rb ./tool/rbinstall.rb --make="make" --dest-dir="" --extout=".ext" --mflags="" --make-flags="" --data-mode=0644 --prog-mode=0755 --installed-list .installed.list --install=all --rdoc-output=".ext/rdoc" 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
======================== Installation successful ==========================
Copying documentation directory... ./ ./GPL … Some of the files created by the installation are inside the build directory: /usr/lcoal/src/ruby-1.9.2-p180
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]: n
Copying files to the temporary directory...OK … Deleting temp dir...OK
Done. The new package has been saved to
/usr/src/redhat/RPMS/x86_64/ruby-1.9.2-p180-1.x86_64.rpm You can install it in your system anytime using:
rpm -i ruby-1.9.2-p180-1.x86_64.rpm
[/sourcecode]
7.RPMファイルのインストールとバージョン確認を行います。
[sourcecode language="bash"]
rpm -ivh --nodeps --nomd5 /usr/src/redhat/RPMS/x86_64/ruby-1.9.2-p180-1.x86_64.rpm
準備中... ########################################### [100%] 1:ruby-1.9.2 ########################################### [100%]
ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux] [/sourcecode]
これでRubyのインストールは完了です。長くなったのでRails3のインストールはまた別にします。