Ruby/Rails on sy*.cs.tamu.edu
I was asked to install Ruby on Rails on a windows server, to be used for class projects. I went with the mongrel via apache approach. I was originally going to install it on IIS runing under FastCGI, but decided against it for a few reasons:
- FastCGI is really only appropriate for a production environment. It’s hard to debug, and this machine is probably going to be used for development, testing, and production.
- Its relatively unstable. FastCGI on IIS is still an awkward combination, and was bound to cause headaches.
- The apache/mongrel approach keeps the two very separate, so it’s easier to find problems.
- To use IIS with Mongrel, you need ISAPI_rewrite, which costs money.
I used this guide, so be sure to look it over if you have any problems.
Step 0: Downloads
Remote desktop into the install machine, and download the following:
Step 1: Install Apache & Ruby
Run the apache installer. Use ”sy
On the next page, click “Custom Install”, and change the installation to “c:\apache”, then choose next and let the installer finish.
Now open the Ruby installer. The default install should be fine.
Step 2: Start the Apache Daemon
Enter the following into a command shell:
cd \
cd apache\apache2\bin
apache –k install
The apache service icon should appear in the task bar.
Step 3: Install Rails & Mongrel
Install the rails, redcloth, and mongrel gems:
gem install rails mongrel mongrel_service redcloth -y
Make sure to choose the win32 option every time it asks.
Step 4: Configure Apache
From the start menu, navigate to “All Programs”->”Apache HTTP Server X”->”Configure Apache Server”->”Edit The Apache http.conf Configuration file”.
Change the line with:
Listen 8080
to:
Listen 80
Note: Binding to port 80 will only work if you don’t have another webserver running on the machine. If you think you might have IIS or something else running on port 80, run:
netstat -a
If you see something like the following:
TCP sy02:http sy02.cs.tamu.edu:0 LISTENING
You may need to change to an open port number. I suggest 81.
Save the file, then start apache using the icon on the bottom right. Enter the following command(change ‘http’ to your port number):
netstat -a | find "http"
It should print out something like:
TCP sy02:http sy02.cs.tamu.edu:0 LISTENING
If you don’t see anything, you have a problem somewhere.
Step 5: Create the Rails App Folder
cd \
mkdir rails_apps
cd rails_apps
rails test_site
cd test_site
ruby script/server –e production
Point your browser to “http://localhost:3000/” ( replace 3000 with whatever port mongrel is running on.), if every thing’s working you should be at the default rails page.
Step 6: Configure Apache to Proxy to Mongrel
Run the following from the command shell:
cd \
cd apache\apache2\conf
(
echo LoadModule proxy_module
modules/mod_proxy.so
echo LoadModule proxy_http_module
modules/mod_proxy_http.so
echo ProxyRequests Off
echo ^<Proxy *^>
echo Order deny,allow
echo Allow from all
echo ^</Proxy^>
) >> http-proxy.conf
(
echo .
echo Include conf/http-proxy.conf
) >> httpd.conf
this should create a http-proxy.conf file in apache’s conf directory. Next run:
set APP_NAME=test_site
set PORT=3000
(
echo .
echo Alias /%APP_NAME% "c:/rails_apps/%APP_NAME%/public"
echo ^<Directory "c:/rails_apps/%APP_NAME%/public"^>
echo Options Indexes FollowSymLinks
echo AllowOverride none
echo Order allow,deny
echo Allow from all
echo ^</Directory^>
echo .
echo ProxyPass /%APP_NAME%/images !
echo ProxyPass /%APP_NAME%/stylesheets !
echo ProxyPass /%APP_NAME%/javascripts !
echo ProxyPass /%APP_NAME%/ http://127.0.0.1:%PORT%/
echo ProxyPass /%APP_NAME% http://127.0.0.1:%PORT%/
echo ProxyPassReverse /%APP_NAME%/ http://127.0.0.1:%PORT%/
) >> http-proxy.conf
Restart apache, browse to “http://localhost/test_site/”, and you should be at your default page.
Step 7: Install Proxy Plugin
Apparently rails needs some help rewriting URL’s to work with the proxy server, so you need to install a rails plugin:
cd \
cd rails_apps\test_site
ruby script/plugin install http://svn.napcsweb.com/public/plugins/reverse_proxy_fix/branches/rails123
http://localhost/test_site
cd vendor\plugins\rails123\lib
echo BASE_URL="http://localhost/test_site" >> config.rb
Step 8: Start mongrel as a service
This will start a mongrel server as a windows service:
mongrel_rails service::install -N test_site
net start test_site
And that should do it. If everything went right, you should get the default rails page again.
Comments
-
I love you ben. That is all.