1. Install Ruby, rails, mongrel, and apache2.2 download one-click Ruby install from the rubyforge website and run the installation program. Then Ruby and rubygems are installed. Run the command: Gem install rails-ygem install mongrel-ygem install mongrel_service-y. After rails and mongrel are installed, download apache2.2 for Windows from the Apache website. After running the installation program, apache2.2 is installed. 2. Start mongrel as a service to start mongrel_rails service: Install-N depot-c d:/rubyproject/depot-P 3000-e production-N to specify the service name, -D indicates the directory of the rails application.-P indicates the TCP port of the mongrel listener, and-e indicates the production mode. In this way, the control panel is opened. | administrative tool | service, you can find that you have added a service named "depot" to manage the service through the control panel. If you need a command line to start and close the service, then: mongrel_rails service: Start-N depotmongrel_rails service: Stop-n depot if you need to log out of the service, then: mongrel_rails service: Remove-N depot if you need to install multiple mongrel instances, you can do this: mongrel_rails service: Install-N depot0-c d: /rubyproject/depot-P 3000-e productionmongrel_rails service: Install-N depot1-c d:/rubyproject/depot-P 3001-e production and so on. 3. Configure apache2.2 and use the editing tool to open CONF/httpd under the directory apache2.2. conf, you need to cancel the comments of the following modules: loadmodule proxy_module modules/mod_proxy.soloadmodule proxy_balancer_module modules/mod_proxy_balancer.soloadmodule proxy_http_module modules/modules if you want to compress the page output, you also need to cancel comm: loadmodule deflate_module modules/mod_deflate.so and configure HTTP Proxy-based load balancing as follows:
XML Code
- Proxyrequests off
- <Proxy balancer: // mycluster>
- Balancermember http: // localhost: 3000
- Balancermember http: // localhost: 3001
- </Proxy>
- <Virtualhost *: 80>
- Servername www.xxx.com
- DocumentRoot D:/rubyproject/Depot/Public
- Proxypass/images!
- Proxypass/stylesheets!
- Proxypass/javascripts!
- Proxypass/balancer: // mycluster/
- Proxypassreverse/balancer: // mycluster/
- Proxypreservehost on
- </Virtualhost>
Mycluster defines each mongrel application server node in the cluster. Proxypass/images! Requests starting with this URL are not forwarded to the mongrel cluster, but are processed by Apache itself. Restart Apache, open a browser to access www.xxx.com, and check whether the configuration is correct. So far, a Ruby on Rails production environment with good stability and performance has been built on Windows server. For page output, you can also use mod_deflate to compress the output content to increase the page download speed, which is left for your own configuration.