I don’t intend this post to be comprehensive (nor introductory) but it will address what worked for me after much googling and finding many contradictory pages on the matter.
For Drupal to use “Clean” URLs, you must enable server URL rewriting. On apache, this is a trivial task. On lighttpd, much less so. Here’s what I did to enable a Drupal directory specific rewrite capability while staying within what appears to be a best practice approach to extending my lighttpd configuration:
- This site’s page on setup worked best for me, (consider this instruction a variation on it) but reading it without understanding some fundamentals on lighttpd will not be helpful
- sudo apt-get install the necessary lighttpd, php5 and mysql packages. I need phpmyadmin, and ubuntu’s setup worked in its default install correctly. There’s plenty of mainstream documentation on this to refer to.
- Do include lighttpd-mod-magnet — we’ll need that.
- Enable the mod_magnet:
sudo lighty-enable-mod magnet - Here’s what is now key to me after re-inventing the wheel: much on-line documentation has you editing the lighttpd.conf quite heavily and without context. Spend 30 minutes NOW on the basic structure of the lighttpd.conf file structure and its ability to specify conditionals. You’ll save hours later. Conditionals allows you to set up specific configurations by virtual hosts, while leaving the defaults alone.
- Notice that lighttpd uses directories to manage module functionality. Fastcgi, phpmyadmin and others are modules that are enabled by their placement in the /etc/lighttpd/conf-enabled directory. Many on-line instructions ignore this fact and have you update the lighttpd.conf file directory directly, when the “right” code is already on your computer. Avoid this trap.
- In the lighttpd.conf file, comment out the lines regarding the “Debian Policy Manual” at the end of the file. It’ll mess up everything else, and I’m curious why they include this, but not enough to dig further.
- Modify your /etc/hosts file so that “drupal.localhost” (the name is arbitrary but you name need to be consistent for your project) points to 127.0.0.1.
- Download the drupal.lua to the /etc/lighttpd/ directory. I got mine from here and it works well:
sudo wget -P /etc/lighttpd/ http://pixel.global-banlist.de/drupal.lua - Update drupal.lua so that the line containing local prefix = ‘/drupal’ matches your needs. For mine, it was an empty string.
- I need a virtual host established so “/root” urls work correctly. So I set one up in the lighttpd.conf file. (Note you can create a conf file per virtual host, or use a mysql mod and store this in my mysql db — but, jeesh, I just want to get back to drupal dev already.) You can make this as complex and sophisticated as you want, the below suits my local machine development needs. You’ll have to make the appropriate path adjustments for your configuration:
$HTTP["host"] == "drupal.localhost" {
server.document-root = "/home/$HOME/Documents/drupal"
index-file.names = ( "index.php" )
url.access-deny = ( "~", ".inc", ".engine", ".install", ".module", ".sh", "sql", ".theme", ".tpl.php", ".xtmpl", "Entries", "Repository", "Root" )
magnet.attract-physical-path-to = ( "/etc/lighttpd/drupal.lua" )
}
Note that magnet. line and it points to the drupal.lua file we downloaded.
After all that drupal 6.6 now allows me to enable clean URLs. I haven’t tested the above instructions from scratch, so reader beware.

