apache+mongrel+rails+linux轻松架设服务器
1.首先在服务器上搭建RAILS环境并装mongrel 和apache
#install ruby
apt-get install irb libdbm-ruby1.8 libgdbm-ruby1.8 libmysql-ruby1.8 libmysqlclient14 libopenssl-ruby1.8 libruby1.8-dbg mysql-common ri ri1.8 ruby1.8-dev
#install rubygem
#http://rubyforge.org/projects/rubygems/
wget http://rubyforge.org/frs/download.php/11289/rubygems-0.9.0.tgz
tar zxfv rubygems-0.9.0.tgz
cd rubygems-0.9.0
ruby setup.rb
gem update –system
#install Rails and dependencies
gem install rails –include-dependencies
#install Mysql
apt-get install mysql-server
#intall Mongrel
apt-get install build-essentia l
gem install mongrel –include-dependencies
2. 配置Apache2
ProxyRequests Off
<Proxy balancer://myCluster>
BalancerMember http://127.0.0.1:3001
BalancerMember http://127.0.0.1:3002
BalancerMember http://127.0.0.1:3003
BalancerMember http://127.0.0.1:3004
BalancerMember http://127.0.0.1:3005
</Proxy>
<VirtualHost *:80>
ServerName *.xxx.com:80
DocumentRoot /usr/xxx/public
ProxyPass /image !
ProxyPass /stylesheets !
ProxyPass /javascripts !
ProxyPass / balancer://myCluster/
ProxyPassReverse / balancer://myCluster/
ProxyPreserveHost on
</VirtualHost>
3.然后在3001,3002...3005端口启动mongrel
mongrel_rails start -e production -p 3001 -d -c /usr/xxx/xxx/ -P /usr/xxx/xxx/log/mongrel-3001.pid
mongrel_rails start -e production -p 3001 -d -c /usr/xxx/xxx/ -P /usr/xxx/xxx/log/mongrel-3002.pid
...
mongrel_rails start -e production -p 3001 -d -c /usr/xxx/xxx/ -P /usr/xxx/xxx/log/mongrel-3005.pid