底下內容個人還沒試過...不過未來應該用的到...先Memo一下...
取自:
http://faq.serverdiy.org/read.php?tid=71
CentOS 5 安裝 ROR
1. 安裝 RubyWorks
安裝 RubyWorks Repo
wget
http://rubyworks.rubyforge.org/public_key.txt
sudo rpm --import public_key.txt
wget
http://rubyworks.rubyforge.org/RubyWorks.repo
cp RubyWorks.repo /etc/yum.repos.d/
用 yum 安裝 RubyWorks
yum install rubyworks 出現下面一堆東西,按 y 一直裝完就是了
--------------------------------------------------------------------------------------------------------
複製內容到剪貼板
代碼:
[root@vmcentos5 ~]# yum install rubyworks
Loading "installonlyn" plugin
Setting up Install Process
Setting up repositories
rubyworks 100% |=========================| 951 B 00:00
base 100% |=========================| 1.1 kB 00:00
updates 100% |=========================| 951 B 00:00
addons 100% |=========================| 951 B 00:00
extras 100% |=========================| 1.1 kB 00:00
Reading repository metadata in from local files
primary.xml.gz 100% |=========================| 2.2 kB 00:00
rubyworks : ################################################## 6/6
Added 6 new packages, deleted 0 old in 0.05 seconds
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for rubyworks to pack into transaction set.
rubyworks-0.0.1-1.i386.rp 100% |=========================| 4.7 kB 00:00
---> Package rubyworks.i386 0:0.0.1-1 set to be updated
--> Running transaction check
--> Processing Dependency: monit >= 4.9 for package: rubyworks
--> Processing Dependency: ruby >= 1.8.5 for package: rubyworks
--> Processing Dependency: ruby-devel >= 1.8.5 for package: rubyworks
--> Processing Dependency: rubygems >= 0.9.2 for package: rubyworks
--> Processing Dependency: haproxy >= 1.2.17 for package: rubyworks
--> Restarting Dependency Resolution with new changes.
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for rubygems to pack into transaction set.
rubygems-0.9.2-1.i386.rpm 100% |=========================| 7.7 kB 00:00
---> Package rubygems.i386 0:0.9.2-1 set to be updated
---> Downloading header for ruby to pack into transaction set.
ruby-1.8.5-5.el5.i386.rpm 100% |=========================| 35 kB 00:00
---> Package ruby.i386 0:1.8.5-5.el5 set to be updated
---> Downloading header for haproxy to pack into transaction set.
haproxy-1.2.17-1.i386.rpm 100% |=========================| 4.4 kB 00:00
---> Package haproxy.i386 0:1.2.17-1 set to be updated
---> Downloading header for ruby-devel to pack into transaction set.
ruby-devel-1.8.5-5.el5.i3 100% |=========================| 22 kB 00:00
---> Package ruby-devel.i386 0:1.8.5-5.el5 set to be updated
---> Downloading header for monit to pack into transaction set.
monit-4.9-1.i386.rpm 100% |=========================| 4.2 kB 00:00
---> Package monit.i386 0:4.9-1 set to be updated
--> Running transaction check
--> Processing Dependency: ruby-libs = 1.8.5-5.el5 for package: ruby-devel
--> Processing Dependency: gcc for package: rubygems
--> Processing Dependency: flex for package: monit
--> Processing Dependency: ruby-libs = 1.8.5-5.el5 for package: ruby
--> Processing Dependency: libcrypto.so.4 for package: monit
--> Processing Dependency: libruby.so.1.8 for package: ruby
--> Processing Dependency: libssl.so.4 for package: monit
--> Processing Dependency: libruby.so.1.8 for package: ruby-devel
--> Restarting Dependency Resolution with new changes.
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for ruby-libs to pack into transaction set.
ruby-libs-1.8.5-5.el5.i38 100% |=========================| 74 kB 00:00
---> Package ruby-libs.i386 0:1.8.5-5.el5 set to be updated
---> Downloading header for gcc to pack into transaction set.
gcc-4.1.1-52.el5.2.i386.r 100% |=========================| 59 kB 00:00
---> Package gcc.i386 0:4.1.1-52.el5.2 set to be updated
---> Downloading header for openssl097a to pack into transaction set.
openssl097a-0.9.7a-9.i386 100% |=========================| 22 kB 00:00
---> Package openssl097a.i386 0:0.9.7a-9 set to be updated
---> Downloading header for flex to pack into transaction set.
flex-2.5.4a-41.fc6.i386.r 100% |=========================| 8.3 kB 00:00
---> Package flex.i386 0:2.5.4a-41.fc6 set to be updated
--> Running transaction check
--> Processing Dependency: libgcc >= 4.1.1-52.el5.2 for package: gcc
--> Processing Dependency: glibc-devel >= 2.2.90-12 for package: gcc
--> Processing Dependency: libgomp.so.1 for package: gcc
--> Processing Dependency: libgomp = 4.1.1-52.el5.2 for package: gcc
--> Processing Dependency: cpp = 4.1.1-52.el5.2 for package: gcc
--> Restarting Dependency Resolution with new changes.
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for glibc-devel to pack into transaction set.
glibc-devel-2.5-12.i386.r 100% |=========================| 105 kB 00:00
---> Package glibc-devel.i386 0:2.5-12 set to be updated
---> Downloading header for libgcc to pack into transaction set.
libgcc-4.1.1-52.el5.2.i38 100% |=========================| 49 kB 00:00
---> Package libgcc.i386 0:4.1.1-52.el5.2 set to be updated
---> Downloading header for cpp to pack into transaction set.
cpp-4.1.1-52.el5.2.i386.r 100% |=========================| 52 kB 00:00
---> Package cpp.i386 0:4.1.1-52.el5.2 set to be updated
---> Downloading header for libgomp to pack into transaction set.
libgomp-4.1.1-52.el5.2.i3 100% |=========================| 49 kB 00:00
---> Package libgomp.i386 0:4.1.1-52.el5.2 set to be updated
--> Running transaction check
--> Processing Dependency: glibc-headers for package: glibc-devel
--> Processing Dependency: glibc-headers = 2.5-12 for package: glibc-devel
--> Restarting Dependency Resolution with new changes.
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for glibc-headers to pack into transaction set.
glibc-headers-2.5-12.i386 100% |=========================| 138 kB 00:00
---> Package glibc-headers.i386 0:2.5-12 set to be updated
--> Running transaction check
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
rubyworks i386 0.0.1-1 rubyworks 19 k
Installing for dependencies:
flex i386 2.5.4a-41.fc6 base 124 k
gcc i386 4.1.1-52.el5.2 updates 4.9 M
glibc-devel i386 2.5-12 base 2.0 M
glibc-headers i386 2.5-12 base 605 k
haproxy i386 1.2.17-1 rubyworks 162 k
libgomp i386 4.1.1-52.el5.2 updates 69 k
monit i386 4.9-1 rubyworks 209 k
openssl097a i386 0.9.7a-9 base 825 k
ruby i386 1.8.5-5.el5 base 278 k
ruby-devel i386 1.8.5-5.el5 base 554 k
ruby-libs i386 1.8.5-5.el5 base 1.6 M
rubygems i386 0.9.2-1 rubyworks 127 k
Updating for dependencies:
cpp i386 4.1.1-52.el5.2 updates 2.6 M
libgcc i386 4.1.1-52.el5.2 updates 82 k
Transaction Summary
=============================================================================
Install 13 Package(s)
Update 2 Package(s)
Remove 0 Package(s)
Total download size: 14 M
Is this ok [y/N]: y
Downloading Packages:
(1/15): ruby-libs-1.8.5-5 100% |=========================| 1.6 MB 00:09
(2/15): glibc-headers-2.5 100% |=========================| 605 kB 00:03
(3/15): rubygems-0.9.2-1. 100% |=========================| 127 kB 00:02
(4/15): gcc-4.1.1-52.el5. 100% |=========================| 4.9 MB 00:27
(5/15): ruby-1.8.5-5.el5. 100% |=========================| 278 kB 00:01
(6/15): glibc-devel-2.5-1 100% |=========================| 2.0 MB 00:11
(7/15): openssl097a-0.9.7 100% |=========================| 825 kB 00:04
(8/15): libgcc-4.1.1-52.e 100% |=========================| 82 kB 00:00
(9/15): flex-2.5.4a-41.fc 100% |=========================| 124 kB 00:00
(10/15): cpp-4.1.1-52.el5 100% |=========================| 2.6 MB 00:06
(11/15): haproxy-1.2.17-1 100% |=========================| 162 kB 00:01
(12/15): libgomp-4.1.1-52 100% |=========================| 69 kB 00:00
(13/15): ruby-devel-1.8.5 100% |=========================| 554 kB 00:01
(14/15): rubyworks-0.0.1- 100% |=========================| 19 kB 00:00
(15/15): monit-4.9-1.i386 100% |=========================| 209 kB 00:01
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID e8562897
Importing GPG key 0xE8562897 "CentOS-5 Key (CentOS 5 Official Signing Key) <centos-5-key@centos.org>" from http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
Is this ok [y/N]: y
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: ruby-libs ####################### [ 1/17]
Installing: ruby ####################### [ 2/17]
Installing: ruby-devel ####################### [ 3/17]
Installing: libgomp ####################### [ 4/17]
Installing: haproxy ####################### [ 5/17]
Updating : cpp ####################### [ 6/17]
Installing: flex ####################### [ 7/17]
Updating : libgcc ####################### [ 8/17]
Installing: openssl097a ####################### [ 9/17]
Installing: monit ####################### [10/17]
Installing: glibc-headers ####################### [11/17]
Installing: glibc-devel ####################### [12/17]
Installing: gcc ####################### [13/17]
Installing: rubygems ####################### [14/17]
Installing: rubyworks ####################### [15/17]
--20:38:03-- http://rubyworks.rubyforge.org/gems.tgz
Resolving rubyworks.rubyforge.org... 205.234.109.18
Connecting to rubyworks.rubyforge.org|205.234.109.18|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 332051 (324K) [application/x-gzip]
Saving to: `/tmp/gems.tgz'
100%[=======================================>] 332,051 156K/s in 2.1s
20:38:06 (156 KB/s) - `/tmp/gems.tgz' saved [332051/332051]
Successfully installed rake, version 0.7.3
Successfully installed daemons, version 1.0.6
Building native extensions. This could take a while...
Successfully installed fastthread, version 1.0
Successfully installed gem_plugin, version 0.2.2
Successfully installed cgi_multipart_eof_fix, version 2.1
Building native extensions. This could take a while...
Successfully installed mongrel, version 1.0.1
Installing a skeleton Rails application into /usr/rails
wget http://rubyworks.rubyforge.org/rails_skeleton.tgz -O /tmp/rails_skeleton.tgz
/tmp/install_skeleton_app.rb:8: warning: Insecure world writable dir /usr, mode 040777
--20:38:12-- http://rubyworks.rubyforge.org/rails_skeleton.tgz
Resolving rubyworks.rubyforge.org... 205.234.109.18
Connecting to rubyworks.rubyforge.org|205.234.109.18|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1597654 (1.5M) [application/x-gzip]
Saving to: `/tmp/rails_skeleton.tgz'
100%[=======================================>] 1,597,654 377K/s in 5.2s
20:38:18 (297 KB/s) - `/tmp/rails_skeleton.tgz' saved [1597654/1597654]
tar -zxf /tmp/rails_skeleton.tgz -C /usr
find /usr/rails -exec chown rails {} \;
find /usr/rails -exec chgrp rails {} \;
Starting Process Monitor (monit): Starting monit daemon with http interface at [127.0.0.1:2812]
[ OK ]
Cleanup : libgcc ####################### [16/17]
Cleanup : cpp ####################### [17/17]
Installed: rubyworks.i386 0:0.0.1-1
Dependency Installed: flex.i386 0:2.5.4a-41.fc6 gcc.i386 0:4.1.1-52.el5.2 glibc-devel.i386 0:2.5-12 glibc-headers.i386 0:2.5-12 haproxy.i386 0:1.2.17-1 libgomp.i386 0:4.1.1-52.el5.2 monit.i386 0:4.9-1 openssl097a.i386 0:0.9.7a-9 ruby.i386 0:1.8.5-5.el5 ruby-devel.i386 0:1.8.5-5.el5 ruby-libs.i386 0:1.8.5-5.el5 rubygems.i386 0:0.9.2-1
Dependency Updated: cpp.i386 0:4.1.1-52.el5.2 libgcc.i386 0:4.1.1-52.el5.2
Complete!
You have mail in /var/spool/mail/root
[root@vmcentos5 ~]#
---------------------------------------------------------------------------------------------------------
安裝好 RubyWorks ,他會把 ruby,rubygems,Mongrel,Haproxy,Monit 安裝跟設定好。但是他不會安裝 Rails ,而是 copy 一份 Rails 在 /usr/rails 上面,這其實是很正確的作法,因為他一開始就取向 Production Server,而 Production Server 本來就該將 Rails 版本 Freeze 在 Rails Doc 裡面。
[root@vmcentos5 ~]# gem i rails -y
Bulk updating Gem source index for:
http://gems.rubyforge.org
ERROR: While executing gem ... (Gem::GemNotFoundException)
Could not find rails (> 0) in any repository
[root@vmcentos5 ~]#
先不管,再往下安裝
2. 安裝 MySQL
RubyWorks 好歸好,就是沒有選擇讓我們裝 DB Server,我們這裡就直接用 yum 安裝 MySQL
yum install mysql-server
3. 安裝 Ruby MySQL Native Lib
我發現到 RubyWorks 並不會安裝 Ruby MySQL Native Lib,所以我們得用 gem 安裝,但是又發現 centos 上面安裝 MySQL Gem 會出現這樣的錯誤訊息,網路上也有人在 complian。
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lm… yes
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lz… yes
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lsocket… no
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lnsl… yes
checking for mysql_query() in -lmysqlclient… no
*** 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
所以得先 remove MySQL 然後再重新安裝 MySQL 跟 MySQL Development Lib
yum remove mysql
yum install mysql
yum install mysql-devel
要在 CentOS 安裝 Rails Gem,那就
gem i rails -y 即可。
gem install mysql -- --with-mysql-include=/usr/include/mysql/mysql --with-mysql-lib=/usr/lib/mysql/
最後那個步驟,會出現
[root@vmcentos5 ~]# gem install mysql -- --with-mysql-include=/usr/include/mysql/mysql --with-mysql-lib=/usr/lib/mysql/Select which gem to install for your platform (i386-linux)
1. mysql 2.7.3 (mswin32)
2. mysql 2.7.1 (mswin32)
3. mysql 2.7 (ruby)
4. mysql 2.6 (ruby)
5. Skip this gem
6. Cancel installation
就選 3 最新的
至於為何這樣,我也不太清楚。能動就好了。
以上是節錄自
http://lightyror.thegiive.net/2007/06/centos-ruby-on-rails.html 有些紅色的是我改過的