Ruby on Rails (RoR) with lighttpd on Windows (getting started)

PLEASE NOTE: Native Lighttpd Windows builds are available at http://en.wlmp-project.net/
The last available Lighttpd for Windows build that I created using Cygwin was Lighttpd for Windows 1.4.17.
Updated September 29, 2009.

The following mini tutorial will start you on your way to setting up a Ruby on Rails development environment. Please note that I do not know how to program in the Ruby language. I am providing this tutorial due to the number of requests that I have received in the posts related to lighttpd. Please note that this basically gets you up and running and using lighttpd rather than Ruby’s built-in WEBrick web server.
This is NOT intended for production machines. If you fail to follow that advice, you are on your own. In fact, I’m not responsible for anything that you do to your machine. I have tested the following instructions on my machine and it worked fine, and I believe it will work fine for yours also. Now that I have claimed no responsibilities for any screw-ups that you may inflict on your computer, here’s the tutorial:

Download RubyForge’s One-Click Ruby Installer: http://rubyforge.org/frs/?group_id=167
Choose the latest “Stable Release” which as of this writing is 1.8.2-15 (ruby182-15.exe).
1. Run the downloaded executable and follow the instructions. Accepting the defaults should be fine unless you have specific reasons to do otherwise.
2. Now install Rails by opening a command window (Start–>Run–>type in ‘cmd’ and press Enter) and then running the command ‘gem install rails –remote’ (without surrounding quotes) and answer “y” for yes to all the dependency questions. UPDATE: please note that the above command has 2 dashes before ‘remote’. WordPress makes two consecutive dashes appear as one.
Download MySQL 4.1 (Windows Essentials 4.1.16 in this case) from a mirror closest to your location: http://dev.mysql.com/get/Downloads/MySQL-4.1/mysql-essential-4.1.16-win32.msi/from/pick#mirrors
1. Run the downloaded msi installer and accept the defaults and skip the mysql.com account sign-up.
2. After clicking ‘Finish’ a configuration wizard will come up. Accept all the defaults except in the security panel you MUST uncheck “Modify Security Settings”. If you fail to do this, Rails will have problems.

Install lighttpd for Windows (download from (link to lighttpd tag on my site)) :
1. Install the downloaded executable, simply follow the directions within the setup.
2. Edit C:lighttpdetclighttpd.conf; set the server.document-root = “C:/rails/cookbook/public”
3. Optionally: change the port number to 81: just uncomment the line that says “server.port = 81”. If you do this step, make sure that in the next section you point to http://127.0.0.1:81

Create an empty Rails application:
1. In the cmd window, type in:
md rails
then:
cd rails
then:
rails cookbook
2. Start lighttpd (Start–>Programs–>lighttpd–>Start lighttpd or double-click the desktop icon if you installed it).
3. Go to http://127.0.0.1 in your web browser. You should see a page that says “Welcome aboard”.

From this point on, I am assuming that you know how to proceed. After all I do not know how to program in Ruby. I hope you found this useful…

Comments on this entry are closed.

  • Roberto Jan 18, 2006 @ 11:10

    ok, that is the easy part, just serving static files ! I tried to configure .cgi, but it simply did not work and nothing was writen into the logfiles. Anybody got a bit further ?

  • Kev Jan 18, 2006 @ 13:20

    For PHP with CGI: in lighttpd.conf, add a line like:
    cgi.assign = ( “.php” => “c:/php/php-cgi.exe” )
    Assuming that is the correct path to your php-cgi.exe

  • chris hulbert Jan 20, 2006 @ 0:34

    To get the ruby on rails to work, use S-CGI. I managed to get it to work (quite nicely) so its possible. Look here: http://www.zedshaw.com/projects/scgi_rails/lighttpd.html

  • Clint Jan 22, 2006 @ 1:26

    In addition to what Kev says above for CGI, you also need to uncomment the mod_cgi line in the server.modules section of lighttpd.conf.

  • Kev Jan 22, 2006 @ 13:07

    Ahh, yes, good point Clint. I left that part out…

  • chris hulbert Jan 22, 2006 @ 17:51

    Heres how to make it work with ruby on rails:
    http://wiki.rubyonrails.org/rails/pages/HowToDeployWithLighttpdOnWindows

  • vruz Jan 23, 2006 @ 18:47

    there’s a slight mispelling in the installation
    instructions, it’s:
    gem install rails –remote
    (note the double hyphen sign)
    experienced users will notice, but new ones
    will hit their head against the wall.
    cheers

  • Kev Jan 24, 2006 @ 6:52

    vruz: Yes, it looks that way, due to the way WordPress handles two dashes. (Even in your comment it appears like one dash) I will make a note of it in the instructions. Thanks.

  • Office 2003 Feb 2, 2006 @ 17:32

    Is it possible to get this blog feed via email? Hanah in Chicago.

  • Kev Feb 3, 2006 @ 6:22

    For RSS 2.0 use: //kevinworthington.com/?feed=rss2 For RSS .92 use: //kevinworthington.com/?feed=rss For Atom 0.3 use: //kevinworthington.com/?feed=atom I don’t know if any of these actually work. I do not use RSS personally.

  • chiank Mar 2, 2006 @ 1:34

    Kev : is PHP+lighttpd for windows work ? I try it on lighttpd 1.4.10a, php 5.1.2 and i got error like this :
    2006-03-02 13:23:25: (configfile.c.746) source: ..etclighttpd.conf line: 221 p
    os: 15 invalid character in variable name
    2006-03-02 13:23:25: (configfile.c.802) configfile parser failed: (
    and line 221 is : cgi.assign = ( “.php” => “c:/php/php-cgi.exe” )
    Thanks
    PS : I already uncomment “mod_cgi”

  • Kev Mar 2, 2006 @ 10:38

    At first, I got the same result as you. But then I noticed that I was missing the closing double-quote after php-cgi.exe and once I closed it, it worked fine. So my advice is to make sure all double-quotes and parentheses are closed properly.

  • chiank Mar 2, 2006 @ 22:59

    weird.. I follow your advise, I retype the double quotes, and viola.. it’s run now.
    thanks.
    cgi.assign = ( “.php” => “C:/php/php-cgi.exe” ) ( After retype)
    cgi.assign = ( “.php” => “C:/php/php-cgi.exe” ) ( Before retype)
    How can Lighttpd said that two lines are different ? :)

  • Kev Mar 3, 2006 @ 8:29

    I don’t know, but I’m glad it works for you. :)

  • Piotr Usewicz Mar 9, 2006 @ 3:08

    These are different. Take a look at the code. The beginning and ending ones are two different characters and HTML encoded with Wordpress’ plugins.

  • Kev Mar 9, 2006 @ 8:49

    Piotr: You are correct. When doing a ‘view-source’ on this page, those two lines ARE indeed different. I guess cutting and pasting was some sort of factor in the confusion. Thanks for the tip.