mouse 2007-9-28 15:05
在 CentOS 5 安裝 Ruby On Rails
取自: [url]http://faq.serverdiy.org/read.php?tid=71[/url]
CentOS 5 安裝 ROR
1. 安裝 RubyWorks
安裝 RubyWorks Repo
wget [url]http://rubyworks.rubyforge.org/public_key.txt[/url]
sudo rpm --import public_key.txt
wget [url]http://rubyworks.rubyforge.org/RubyWorks.repo[/url]
cp RubyWorks.repo /etc/yum.repos.d/
用 yum 安裝 RubyWorks
yum install rubyworks 出現下面一堆東西,按 y 一直裝完就是了
[root@vmcentos5 ~]# yum install rubyworks
安裝好 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: [url]http://gems.rubyforge.org[/url]
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 最新的
至於為何這樣,我也不太清楚。能動就好了。