Lighttpd to the rescue!

Our home server — we call him Rupert — is a real trooper.  Beneath his yellowing beige exterior, a first-gen Pentium 4 works its 224 MB of RAM night and day delivering a variety of services to our home network.  On top of storing our files, caching our DNS requests, filtering the Web for little eyes, and providing me a handy back-door into the network via SSH, rupert’s most important job is delivering a selection of web applications to our home network.

One of the most important — and unfortunately the bulkiest — is Moodle.  Moodle is a CMS designed for schools that deliver online classes and content, and it’s proven quite valuable over the last couple years as an aid in our homeschooling.  Sadly, though, poor Rupert has a tough time dishing out the Moodles.

Now, being a Linux server admin, I’m used to dealing with hardware that can easily (and often have to) dispense web content by the megabyte to hundreds of visitors every hour.  So when I conjured Rupert from a pile of parts, I naturally installed THE most popular HTTP server ever, Apache (version 2).   But with Moodle causing Rupert to sound the ballast alarm, it was obviously time to lighten the load.  Enter Lighttpd.


Don’t ask me how to pronounce Lighttpd, I think most people just call it “Lighty” for short.  I thought it’d be an arduous journey replacing Apache with Lighty, but as it turned out (thanks in part to Debian) I was done within 10 minutes.  Here’s what I did:

  1. I backed up apache’s settings by making a tarball of the /etc/apache2 folder.  Good thing I did, too, because it turns out we have to translate some settings later on.
  2. Next, I shut down apache2 so it wouldn’t be using port 80 anymore.  On Debian the command is:
    service apache2 stop
  3. Now install lighttpd and php-cgi; Debian dependency handling takes care of the dependencies.
  4. Lighttpd is now running it defaults to /var/www as its web root, so if you were using the default apache2 webroot on Debian everything’s set to go.
  5. Of course, we need php enabled, right?  Fortunately that’s pretty simple:
    lighttpd-enable-mod fastcgi-php
    lighttpd-enable-mod fastcgi
    service lighttpd restart

Some fixes

Once I’d got this far, most of my sites were working great, so I removed apache from the server so it wouldn’t conflict on reboot. However, moodle and dokuwiki weren’t working; they came up “site not found”. The reason was simple: these applications are not directly under the webroot, they exist elsewhere on the filesystem and apache serves them using an “alias” directive.

The fix was also simple; in place of the alias (which, for example, directed the url “/wiki” to “/usr/share/dokuwiki”), I created a symlink under /var/www to the location of the application, like so:

ln -s /usr/share/dokuwiki /var/www/wiki
ln -s /usr/share/moodle /var/www/moodle

…and so on for each application like that. Now, there may be some security issues here, but since this is a server exclusively available on my home LAN, that wasn’t a concern for me.  If you’re trying this on a public server, make sure you double-check the security concerns!

One final tweak I did: I disabled http compression.  Compression is great for servers running on the web,  where bandwidth is likely to be a bottleneck. On a home LAN, we have bandwidth to spare, but the server itself needs to conserve CPU.  Shutting off compression made a significant speed increase on moodle, where each page hit loads in several files, and it was as easy as editing /etc/lighttpd/lighttpd.conf and commenting out the line starting with “compress.filetype”.


So far things are pretty satisfactory with lighttpd — the server’s RAM usage has dropped significantly, and I believe we can now actually have more than one child using moodle at the same time 🙂 !  Have you had a good experience with Lighttpd?  Feel free to comment about it!

Leave a Reply

Your email address will not be published. Required fields are marked *