First, install Ruby, rails, mongrel and Apache2.2



Rubyforge download from the web site One-Click Ruby Install, run setup on installed ruby and rubygems.



Run the command:

gem install rails-y

gem install mongrel-y

gem install mongrel_service-y

Installed rails and Mongrel



Windows download from the Apache Web site version of the Apache2.2, run setup, it installed Apache2.2.



Second, put Mongrel start as Services



mongrel_rails service:: install-N depot-cd: \ Rubyproject \ depot-p 3000-e production

-N to specify the service name,-d specify the rails application directory,-p are Mongrel listening tcp port,-e is the startup mode to production mode



This open Control Panel | Administrative Tools | Services, we will find that an increase of a project called "depot" of the Service, you can through the Control Panel to manage the service. If you need the command line to start and turn off the service, then:

mongrel_rails service:: start-N depot

mongrel_rails service:: stop-N depot



If you need to write-off from the services of the service, then:

mongrel_rails service:: remove-N depot



If you need to install multiple Mongrel instances, it can do:

mongrel_rails service:: install-N depot0-cd: \ Rubyproject \ depot-p 3000-e production

mongrel_rails service:: install-N depot1-cd: \ Rubyproject \ depot-p 3001-e production

And so on.



Three, configure Apache2.2



Use editing tools to open the following Apache2.2 directory conf / httpd.conf, to cancel the following module Notes:

LoadModule proxy_module modules / mod_proxy.so

LoadModule proxy_balancer_module modules / mod_proxy_balancer.so

LoadModule proxy_http_module modules / mod_proxy_http.so

If you wish to use the compression of the output page, but also required the abolition of the following modules Note:

LoadModule deflate_module modules / mod_deflate.so



And according to the following configuration of the agent-based HTTP load balancing:

xml code


  1. ProxyRequests Off
  2. <Proxy Balancer://myCluster>
  3. BalancerMember http://localhost:3000
  4. BalancerMember http://localhost:3001
  5. </ Proxy>
  6. <VirtualHost *:80>
  7. ServerName www.xxx.com
  8. DocumentRoot d: / rubyproject / depot / public
  9. ProxyPass / images!
  10. ProxyPass / stylesheets!
  11. ProxyPass / javascripts!
  12. ProxyPass / balancer: / / myCluster /
  13. ProxyPassReverse / balancer: / / myCluster /
  14. ProxyPreserveHost on
  15. </ VirtualHost>




myCluster defined Mongrel cluster for each application server node. ProxyPass / images! Specified in the beginning of the URL request does not give agent Mongrel cluster, and their treatment by the Apache. Re-starting Apache, then open the browser to visit www.xxx.com Check configuration is correct.



At this point, in a Windows Server above have good stability and performance of Ruby on rails production environment on the structures better.



The page output, you can also use mod_deflate to compress output in order to enhance page download speed, the U.S. on the left to its own configured.