在 CentOS 安裝 Ruby on Rails

昨天在 CentOS 安裝 Ruby on Rails 的時候,我發現到雖然用 RubyWorks 來安裝很快,但是有些小細節還是得注意。所以還是寫一個 Tutorial 好了。



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
安裝好 RubyWorks ,他會把 ruby,rubygems,Mongrel,Haproxy,Monit 安裝跟設定好。但是他不會安裝 Rails ,而是 copy 一份 Rails 在 /usr/rails 上面,這其實是很正確的作法,因為他一開始就取向 Production Server,而 Production Server 本來就該將 Rails 版本 Freeze 在 Rails Doc 裡面。但是如果還是要在 CentOS 安裝 Rails Gem,那就
gem i rails -y
即可。

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
gem install mysql
至於為何這樣,我也不太清楚。反正 work 就好啦。

這樣應該就安裝完成了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值