Ubuntu 7.1 server从无到有搭建jsp/php/rails全能WEB生产环境

五、安装Rails环境

Rails环境使用Mongrel架设。1、安装rubytar -zxvf ruby-1.8.6.tar.gzcd
ruby-1.8.6./configure prefix=/usr/local/rubymakemake install

将ruby加入PATHvi
/etc/profileRUBY_HOME=/usr/local/rubyPATH=${RUBY_HOME}/bin:${JAVA_HOME}/bin:/usr/local/mysql/bin:${PATH}export
PATH

退出root,重新用root登陆,验证ruby是否安装成功ruby
-v显示版本号,说明安装成功

2、安装gemtar -zxvf rubygems-0.9.4.tgzcd rubygems-0.9.4ruby setup.rb

澳门新葡亰网站注册,rubygems-0.9.5好像有问题,无论gem什么包都说ssl没有安装,重新安装个rubygems-0.9.4就没问题了。3、安装rails/mongrel/termiosapt-get
install libssl-devgem install rake include-dependenciesgem install rails
include-dependenciesgem install termios include-dependenciesgem install
mongrel include-dependenciesgem install mongrel_cluster
include-dependencies

生成一个默认站点后,转到站点目录mongrel_rails cluster::configure -e
production -p 8000 -N 3 -c /home/dingl/rails-web/ -a
127.0.0.1在database.yml中配置好数据库,这里是生产环境,配置production段。如果需要使用socket方式连接mysql,增加:socket:
/tmp/mysql.sock同时还可以指定数据传输编码:encoding: utf8

4、启动mongrel:mongrel_rails cluster::start

如果出现以下错误:Cannot find gem for Rails ~1.2.3.0:Install the missing
gem with gem install -v=1.2.3
rails则修改config/environment.rb里rails的版本号即可

5、配置Apache与Mongrel:

修改apache的配置文件:vi
/usr/local/apache/conf/在文件最后增加一个虚拟主机:VirtualHost *:80
ServerName RewriteEngine On DocumentRoot /home/dingl/rails-web/
ProxyRequests Off Proxy balancer://mongrel_cluster BalancerMember