CentOS 5 安裝 ROR
Updated 2012/7/30if you are using ubuntu 12, try
sudo aptitude install libmysqlclient-dev
1. 安裝 RubyWorks
安裝 RubyWorks Repo
wget http://rubyworks.rubyforge.org/public_key.txtsudo rpm --import public_key.txtwget http://rubyworks.rubyforge.org/RubyWorks.repocp RubyWorks.repo /etc/yum.repos.d/
用 yum 安裝 RubyWorks
yum install rubyworks 出現下面一堆東西,按 y 一直裝完就是了
--------------------------------------------------------------------------------------------------------
# yum install rubyworksLoading "installonlyn" pluginSetting up Install ProcessSetting up repositoriesrubyworks 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 filesprimary.xml.gz 100% |=========================| 2.2 kB 00:00 rubyworks : ################################################## 6/6Added 6 new packages, deleted 0 old in 0.05 secondsParsing package install argumentsResolving 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 checkDependencies Resolved=============================================================================Package Arch Version Repository Size =============================================================================Installing:rubyworks i386 0.0.1-1 rubyworks 19 kInstalling for dependencies:flex i386 2.5.4a-41.fc6 base 124 kgcc i386 4.1.1-52.el5.2 updates 4.9 Mglibc-devel i386 2.5-12 base 2.0 Mglibc-headers i386 2.5-12 base 605 khaproxy i386 1.2.17-1 rubyworks 162 klibgomp i386 4.1.1-52.el5.2 updates 69 kmonit i386 4.9-1 rubyworks 209 kopenssl097a i386 0.9.7a-9 base 825 kruby i386 1.8.5-5.el5 base 278 kruby-devel i386 1.8.5-5.el5 base 554 kruby-libs i386 1.8.5-5.el5 base 1.6 Mrubygems i386 0.9.2-1 rubyworks 127 kUpdating for dependencies:cpp i386 4.1.1-52.el5.2 updates 2.6 Mlibgcc i386 4.1.1-52.el5.2 updates 82 kTransaction Summary=============================================================================Install 13 Package(s) Update 2 Package(s) Remove 0 Package(s) Total download size: 14 MIs this ok : yDownloading 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 e8562897Importing GPG key 0xE8562897 "CentOS-5 Key (CentOS 5 Official Signing Key) " from http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5Is this ok : yRunning Transaction TestFinished Transaction TestTransaction Test SucceededRunning TransactionInstalling: 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 ####################### Installing: glibc-headers ####################### Installing: glibc-devel ####################### Installing: gcc ####################### Installing: rubygems ####################### Installing: rubyworks ####################### --20:38:03-- http://rubyworks.rubyforge.org/gems.tgzResolving rubyworks.rubyforge.org... 205.234.109.18Connecting to rubyworks.rubyforge.org|205.234.109.18|:80... connected.HTTP request sent, awaiting response... 200 OKLength: 332051 (324K) Saving to: `/tmp/gems.tgz'100%[=======================================>] 332,051 156K/s in 2.1s 20:38:06 (156 KB/s) - `/tmp/gems.tgz' saved Successfully installed rake, version 0.7.3Successfully installed daemons, version 1.0.6Building native extensions. This could take a while...Successfully installed fastthread, version 1.0Successfully installed gem_plugin, version 0.2.2Successfully installed cgi_multipart_eof_fix, version 2.1Building native extensions. This could take a while...Successfully installed mongrel, version 1.0.1Installing a skeleton Rails application into /usr/railswget 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.tgzResolving rubyworks.rubyforge.org... 205.234.109.18Connecting to rubyworks.rubyforge.org|205.234.109.18|:80... connected.HTTP request sent, awaiting response... 200 OKLength: 1597654 (1.5M) 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 tar -zxf /tmp/rails_skeleton.tgz -C /usrfind /usr/rails -exec chown rails {} \;find /usr/rails -exec chgrp rails {} \;Starting Process Monitor (monit): Starting monit daemon with http interface at [ OK ]Cleanup : libgcc ####################### Cleanup : cpp ####################### Installed: rubyworks.i386 0:0.0.1-1Dependency 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-1Dependency Updated: cpp.i386 0:4.1.1-52.el5.2 libgcc.i386 0:4.1.1-52.el5.2Complete!You have mail in /var/spool/mail/root# ---------------------------------------------------------------------------------------------------------安裝好 RubyWorks ,他會把 ruby,rubygems,Mongrel,Haproxy,Monit 安裝跟設定好。但是他不會安裝 Rails ,而是 copy 一份 Rails 在 /usr/rails 上面,這其實是很正確的作法,因為他一開始就取向 Production Server,而 Production Server 本來就該將 Rails 版本 Freeze 在 Rails Doc 裡面。# gem i rails -yBulk updating Gem source index for: http://gems.rubyforge.orgERROR: While executing gem ... (Gem::GemNotFoundException)Could not find rails (> 0) in any repository#
先不管,再往下安裝
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 mysqlyum install mysqlyum 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/最後那個步驟,會出現
# 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 gem6. Cancel installation
就選 3 最新的
至於為何這樣,我也不太清楚。能動就好了。
以上是節錄自 http://lightyror.thegiive.net/2007/06/centos-ruby-on-rails.html 有些紅色的是我改過的
页:
[1]