在 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 就好啦。

這樣應該就安裝完成了。

你可能感兴趣的:(Rails,CentOS,Ruby,MySQL,rubygems)