SoShellon 2011-08-08
第一步:Amazon Linux默认安装ruby,所以要移除原来的ruby。
sudo yum remove -y ruby
第二步:安装编译环境和mysql。
sudo yum install -y gcc make patch zlib-devel openssl-devel c++ gcc gcc-c++ gcc-c++ readline-devel curl-devel mysql mysql-server curl mysql-devel
第三步:下载最新版本REE,并编译安装。
mkdir ~/src
cd~/src
wgethttp://rubyenterpriseedition.googlecode.com/files/ruby-enterprise-1.8.7-2011.03.tar.gz
tarxzvfruby-enterprise-1.8.7-2011.03.tar.gz
sudo ./ruby-enterprise-1.8.7-2011.03/installersudo ln -s /opt/ruby-enterprise-1.8.7-2011.03/bin/ruby /usr/bin/ruby
sudoln-s/opt/ruby-enterprise-1.8.7-2011.03/bin/gem/usr/bin/gem
sudoln-s/opt/ruby-enterprise-1.8.7-2011.03/bin/rake/usr/bin/rake
sudo ln -s /opt/ruby-enterprise-1.8.7-2011.03/bin/bundle /usr/bin/bundle如果你想卸载REE,仅仅是删除安装目录。
rm /opt/ruby-enterprise-1.8.7-2011.03
第四步:启动mysql,并设置root新密码。
sudo service mysqld start/usr/bin/mysqladmin -u root password 'new-password'
第五步:设置mysql自启动
sudo chkconfig mysqld on
(上述命令不会出现任何提示,直接回车即可)
第六步:安装Phusion Passenger (http://www.modrails.com)集成REE。
sudo /opt/ruby-enterprise-1.8.7-2011.03/bin/passenger-install-nginx-module
安装完成后会在/opt/nginx/conf/nginx.conf配置文件中添加以下语句:
http {
...
passenger_root/opt/ruby-enterprise-1.8.7-2011.03/lib/ruby/gems/1.8/gems/passenger-3.0.8;
passenger_ruby/opt/ruby-enterprise-1.8.7-2011.03/bin/ruby;
...
}第七步:配置Ruby on Rails程序,并启动nginx。
sudo ln -s /opt/ruby-enterprise-1.8.7-2011.03/bin/rails /usr/bin/rails
如果你的Rails程序在目录“/somewhere”中,你主机的域名为“www.yourhost.com”,nginx.conf文件就应该大概如下:
server {
listen80;
server_namewww.yourhost.com;
root/somewhere/public;#<---besuretopointto'public'!
passenger_enabledon;
}启动nginx:
sudo ln -s /opt/nginx/sbin/nginx /usr/bin/nginx
或者
export PATH=/opt/ruby-enterprise-1.8.7-2011.03/bin:$PATH
sudo /usr/bin/nginx
第八步:查看用户安装指南和优化提示。
more '/opt/ruby-enterprise-1.8.7-2011.03/lib/ruby/gems/1.8/gems/passenger-3.0.8/doc/Users guide Nginx.html'
或者访问网站:http://www.modrails.com/documentation/Users%20guide%20Nginx.html