What you need:
Windows NT/2000/XP/Server 2003
Apache httpd 2.0.54 installed
Connection to Broadband
Ability to install software and enough diskspace
Now that we have established what we need, lets get cracking.
Installing Ruby, Gems and Rails:
Download and execute the following:
http://rubyforge.org/frs/download.php/11926/ruby184-20.exe
This will install ruby 1.8.4 on your PC.
http://rubyforge.org/frs/download.php/11290/rubygems-0.9.0.zip
Unzip rubygems-0.9.0.zip into C:\. This will create C:\rubygems-0.9.0 directory.
C: CD \rubygems-0.9.0 ruby setup.rb gem install rails --include-dependencies
Now that you are done with Ruby, Gems and Rails, next bit is to download latest mod_scgi.so Apache module.
Download:
http://www.zedshaw.com/downloads/scgi_rails/apache2-mod_scgi-1.7a-win32.zip
http://www.zedshaw.com/downloads/scgi_rails/scgi_rails-0.4.3.gem
Unzip apache2-mod_scgi-1.7a-win32.zip into your Apache\modules directory. This should create the mod_scgi.so file there.
After this, you will need the mod_scgi.so module to be loaded. For this, add the following to your Apache httpd.conf:
LoadModule scgi_module modules/mod_scgi.so
Before we can make use of the Apache SCGI module, we will need to install the SCGI gem.
Before that, install the following 2 gems:
gem install scgi_rails-0.4.3.gem
All the installations are done. Now, lets create a rails application and make it available over the internet.
C: cd \ rails myapp cd myapp scgi_ctrl config -e development -S <provide a password for configuration>
httpd.conf VirtualHost example configuration:
<VirtualHost your-ip:80> AddDefaultCharset utf-8 ServerName <a href="http://www.yourdomain.com">www.yourdomain.com</a> DocumentRoot c:/myapp/public ErrorDocument 500 /500.html ErrorDocument 404 /404.html # handle all requests throug SCGI SCGIMount /myapp 127.0.0.1:9999 # matches locations with a dot following at least one more characters, that is, things like *,html, *.css, *.js, which should be delivered directly from the filesystem <LocationMatch \..+$> # don't handle those with SCGI SCGIHandler Off </LocationMatch> <Directory c:/myapp/public/> Options +FollowSymLinks AllowOverride All Order allow,deny allow from all </Directory> </VirtualHost>
Your public/.htaccess file should look like:
Options +FollowSymLinks +ExecCGI RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ /rails/dispatch.cgi/$1 [QSA,L] ErrorDocument 500 "<h2>Application error</h2>Rails application failed to start properly"
We are now ready to show off our rails app to the world.
Start SCGI.
C: cd \myapp scgi_service
After this, restart your apache httpd.
Visit the URL http://localhost and you should see the welcome screen. Next, visit http://localhost/myapp and the rails app should be available there.
Original topic at: PuneRuby
Email: ashish@sapforbusiness.com
See Also: