Before I start, I’d like to make it clear that 95% of this code came from Evan Fosmark, who also had the original idea.  I’ve just mashed together some different bits of code and customised it to meet my needs!

When I migrated my website from my old hosting account over to my Virtual Private Server yesterday, I soon realised I had overlooked something that, if left unchanged, would end up annoying me quire a bit – directory listings.

My VPS only has 128MB guaranteed RAM, and that means it’s running lighttpd instead of the altogether meatier Apache.  This doesn’t bother me in the slightest – if anything, I prefer lighttpd anyway.  I’ve learned how to use it over the past few months and I find it fast, easily-configured, and definitely ‘light’!  One of the sacrifices you make for this lightness, however, is that the directory listings aren’t anywhere near as fancy as Apache’s.  There are no filetype icons, and no option for sorting the file list by date/size/type.

This led me to look for another way of generating directory listings for my stuff subdomain, which probably gets more use than the main site because it’s where I plonk all the random things that I need to share, but don’t deserve their own page on the site.  Finding Evan Fosmark’s Enhanced Lighttpd directory generator saved me from having to use my meagre PHP knowledge to write my own script, but it only worked for the root folder that the index.php was placed in.  I wanted it to work, or at least appear to work, for the subfolders too!  This is where I remembered mod_rewrite:

  1. Stick my modified index.php into your root folder and remove the .txt extension
  2. Add the following to lighttpd.conf (or make your own config file, I saved mine in with the rest of my subdomain configs):
    $HTTP["host"] =~ "stuff\.jontysewell\.net" {
              url.rewrite = ( "^/(?!(.+\.\w*)).*$" => "/index.php?q=$0" )
    }

    Obviously, replace the host line as required.  This regex will make sure that any directories are sent to the generator to have nice indexes made, while files aren’t redirected and are downloaded normally.

  3. Get the CSS file I use from here, and edit the $css_file variable at the top of index.php to reference wherever you put it.
  4. To get fancy pants filetype icons like I have, download whatever icon set you like (I’m using Tango icons) and save the relevant files into an .icons folder in the same folder as your CSS.  (thanks to Jace for this bit of script)

And that’s about it, I think!  If you found that hard to follow, bear in mind it’s the first time I’ve written a guide for this sort of thing, and feel free to ask for help if you need it.  I can’t guarantee I’ll reply within any reasonable timeframe, but it’s worth trying!

If I ever get some more time I’d like to modify the script further so that I can put one copy of it in a central place, and use lighttpd rules to give fancy listings to any number of subdomains.

The winter of 2009/10 has certainly seen more than its normal amount of wintry weather for Derbyshire.  During the first snowfall in December I decided to pick up the camera and go for a walk through Holymoorside – a very picturesque place to be at any time of the year!  Here are some of the photos I took.

That's right, I've finally got around to installing a WYSIWYG editor!  I'm using CKEditor, which looks pretty good.  As well as that, I've decided to consolidate my assets (and save some money) and migrate my website and hosting onto my VPS.  Apart from this actually giving my VPS something to do, there shouldn't be anything different at your end.  Funnily enough, it should actually work better than it used to!  I never realised but the old installation wasn't using the correct font for some reason, and now it is, and I think I prefer it this way.

I just need to figure out some e-mail forwarders so that my @jontysewell.net addresses continue to work, and that should be it.  If there is anything you find that doesn't work, please send me an e-mail and I'll try to fix it – there's a lot of little things that I don't have time to test.

Nothing else much seems to have changed on the site, I'm just pleased that I can do things like this and this now without much effort. :p


Oh, and there are new smileys, too. The old smiley plugin never really worked.