the blog
Back to -Blog

LightTPD: Tripping the light fantastic ...

Using the latest version of LightTPD with Ruby In Steel
by Dermot Hogan
Saturday 2 August 2008.

I’ve just been checking out the latest release of LightTPD. It has a much better installer than when I first looked at it a couple of years back. Even better, it now runs as a Windows ‘service’ which means that you can set it up to run in the background and once set up you can forget about it. However, setting it up isn’t quite as simple as it could be, so I’ve outlined the steps required to get it going.

First off, download LightTPD (pronounced ’lighty’). Then (assuming that you’ve got Ruby and Rails installed) you need to get the following gems: highline, cmdparse and scgi_rails. The latter is available from Zed Shaw’s website though we will also be bundling it in our upcoming 1.3 release.

I wanted to use SQLServer – we use this database as our source control system with Microsoft’s excellent TeamServer. I’ve nothing against Subversion, indeed I’ve used both it and TeamServer extensively. It’s just that TeamServer works, has an integrated bug/task reporting and tracking system and fits very nicely into Visual Studio. Of course, the downside is that you have to pay for TeamServer. Anyway, to use SQLServer, you’ll need the activerecord-sqlserver-adapter gem and also remember to install ado.rb in C:\ruby\lib\ruby\site_ruby\1.8\DBD\ADO (see the SQLServer tutorial).

Now install LightTPD. You’ll notice that it now installs into somewhere civilized like C:\Program Files\LightTPD and this version (1.4.19) doesn’t seem to be quite as pernickety as to where the binaries actually live unlike the previous version (1.4.13) I tested against.

Now run Service-Install.exe (it’s in the bin directory). This will install the LightTPD service, but when prompted, don’t start the service as we’ll need to change a setting.

Now the awkward bit. Open the Registry Editor and select HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LightTPD. In the Parameters sub-key, select AppParameters and change the -f argument to point to the LightTPD configuration file you want to use. This is normally in the Rails application’s config directory, but it can be anywhere. For example, for my standard Blog application (built using Huw’s excellent tutorial) the AppParameters string looks like: -f "C:\Data\Blog\Blog\config\lighttpd.conf" -m lib –D

In the LightTPD configuration file (built by Ruby In Steel), there are really just two parameters that may need to be set. First is the port number. IIS uses the default 80 on my machine, so I’ve set the default to 81. If you need to change this got to this line in lighttpd.conf:

server.port = 81

The second thing to set is the ‘root’ for any HTTP requests:

server.document-root = "C:/Data/Blog/Blog/public/"

Normally, this is set by Ruby In Steel when it generates a new Rails project, but of course you can change this if you wish.

Start the LightTPD service:

And try the usual http://localhost:81/ to get the Rails Welcome page, just to make sure everything is ok.

You don’t have to run LightTPD as a service – you can just run it from Ruby In Steel’s Start Server menu item. But if you’ve got just one application you regularly use, then it’s a good idea. Further, you can have several LightTPD services running which you will be able to choose between using the new configuration dependent Property Pages in the forthcoming Ruby In Steel 1.3 (which I’ll have more to say about soon).

Overall, I really like LightTPD – I can see why it’s got a very good reputation. It’s now got a decent Windows installer, the service setup is simple (though it could be better – poking around in the Registry is uncivilized). It’s fast, easy to configure and, well, it just works. What more can I say?

Bookmark and Share   Keywords:  tools  tutorial
© SapphireSteel Software 2014