Now that your environment has been properly configured to run Rails applications, we must configure Windows to automatically launch the required processes. We will configure Mongrel to launch and run individual instances of the Rails application, and lighttpd to proxy requests from IIS to the Mongrel processes.
Mongrel is an application server. Each Mongrel process will run one instance of the Rails application. For demonstration purposes we will set up two Mongrel processes.
Type each of the following lines and press ENTER after each:
mongrel_rails service::install -N rails_app_4001 -p 4001
mongrel_rails service::install -N rails_app_4002 -p 4002
This creates two Windows Services, "rails_app_4001" and "rails_app_4002".
Type each of the following lines and press ENTER after each:
net start rails_app_4001
net start rails_app_4002
This starts each of the Windows Services we just created.
Open a browser window and navigate to each of the following URLs.
You should see the same "Welcome aboard" message as in Section 1 - Step 11.
Open "Services" from the "Administrative Tools" menu on the Start Menu.
Locate the "rails_app_4001" and "rails_app_4002" services. For each of these, do the following:
Close the Services window, Command Prompt, and any web browser windows previously opened.
Mongrel configuration as a Windows Service is complete.
lighttpd is very fast web server with proxy capabilities. We will use it to distribute requests to our Mongrel processes.
Type the following and press ENTER:
instsrv lighttpd "C:\Program Files\Windows Resource Kits\Tools\srvany.exe"Open the "Run" command from the Start Menu. Type the following and press ENTER:
regeditLocate the following registry key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lighttpd
Double-click the String Value "Application" and enter the following for "Value data:"
"C:\Program Files\LightTPD\LightTPD.exe"
Click "OK."
Right-click the key "Parameters" (appearing as a subfolder of "lighttpd" named "Parameters"), and click "New," and "String Value." Name the String Value "AppParameters" and press ENTER.
Double-click the String Value "AppParameters" and enter the following for "Value data:"
Note: The following lines should be entered as one line with a single space in between. This line has been broken into two for publishing purposes.
-f "C:\test\testapp\config\lighttpd.conf"
-m "C:\Program Files\LightTPD\lib" -D
Click "OK" and then close the Registry Editor.
Open "Services" from the "Administrative Tools" menu on the Start Menu.
lighttpd configuration as a Windows Service is complete. lighttpd will by default launch and proxy requests to the two Mongrel processes. It will listen on port 8001 on localhost only.
Type the following into the editor:
RewriteProxy (.*) http://localhost:8001/$1Click "Apply." The Helicon Config Editor will close.
IIS configuration is complete.
This concludes the Ruby on Rails setup for Windows. Your server will now proxy all requests to the lighttpd service, which in turn distributes requests to each of the Mongrel services configured.
When configuring additional applications in the future there will generally be no new installations necessary. You will simply configure new Mongrel and lighttpd Windows Services.
Previous Page | 1 | 2 | 3