{"id":146,"date":"2011-09-26T22:30:08","date_gmt":"2011-09-27T03:30:08","guid":{"rendered":"http:\/\/www.alandmoore.com\/blog\/?p=146"},"modified":"2011-10-04T22:14:51","modified_gmt":"2011-10-05T03:14:51","slug":"lighttpd-to-the-rescue","status":"publish","type":"post","link":"https:\/\/alandmoore.com\/blog\/2011\/09\/26\/lighttpd-to-the-rescue\/","title":{"rendered":"Lighttpd to the rescue!"},"content":{"rendered":"<p>Our home server &#8212; we call him Rupert &#8212; is a real trooper. \u00a0Beneath 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. \u00a0On 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&#8217;s most important job is delivering a selection of web applications to our home network.<\/p>\n<p>One of the most important &#8212; and unfortunately the bulkiest &#8212; is <a title=\"Moodle Moodle Moodle!\" href=\"http:\/\/www.moodle.org\" target=\"_blank\">Moodle<\/a>. \u00a0Moodle is a CMS designed for schools that deliver online classes and content, and it&#8217;s proven quite valuable over the last couple years as an aid in our homeschooling. \u00a0Sadly, though, poor Rupert has a tough time dishing out the Moodles.<!--more--><\/p>\n<p>Now, being a Linux server admin, I&#8217;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. \u00a0So when I conjured Rupert from a pile of parts, I naturally installed <em>THE<\/em>\u00a0most popular HTTP server ever, Apache (version 2). \u00a0 But with Moodle causing Rupert to sound the ballast alarm, it was obviously time to lighten the load. \u00a0Enter Lighttpd.<\/p>\n<h2>Installing<\/h2>\n<p>Don&#8217;t ask me how to pronounce Lighttpd, I think most people just call it &#8220;Lighty&#8221; for short. \u00a0I thought it&#8217;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. \u00a0Here&#8217;s what I did:<\/p>\n<ol>\n<li>I backed up apache&#8217;s settings by making a tarball of the \/etc\/apache2 folder. \u00a0Good thing I did, too, because it turns out we have to translate some settings later on.<\/li>\n<li>Next, I shut down apache2 so it wouldn&#8217;t be using port 80 anymore. \u00a0On Debian the command is:\n<pre lang=\"bash\">service apache2 stop<\/pre>\n<\/li>\n<li>Now install lighttpd and php-cgi; Debian dependency handling takes care of the dependencies.<\/li>\n<li>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&#8217;s set to go.<\/li>\n<li>Of course, we need php enabled, right? \u00a0Fortunately that&#8217;s pretty simple:\n<pre lang=\"ini\">lighttpd-enable-mod fastcgi-php\r\nlighttpd-enable-mod fastcgi\r\nservice lighttpd restart\r\n<\/pre>\n<\/li>\n<\/ol>\n<h2>Some fixes<\/h2>\n<p>Once I&#8217;d got this far, most of my sites were working great, so I removed apache from the server so it wouldn&#8217;t conflict on reboot. However, moodle and dokuwiki weren&#8217;t working; they came up &#8220;site not found&#8221;. The reason was simple: these applications are not directly under the webroot, they exist elsewhere on the filesystem and apache serves them using an &#8220;alias&#8221; directive.<\/p>\n<p>The fix was also simple; in place of the alias (which, for example, directed the url &#8220;\/wiki&#8221; to &#8220;\/usr\/share\/dokuwiki&#8221;), I created a symlink under \/var\/www to the location of the application, like so:<\/p>\n<pre lang=\"bash\">\r\nln -s \/usr\/share\/dokuwiki \/var\/www\/wiki\r\nln -s \/usr\/share\/moodle \/var\/www\/moodle\r\n<\/pre>\n<p>&#8230;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&#8217;t a concern for me. \u00a0If you&#8217;re trying this on a public server, make sure you double-check the security concerns!<\/p>\n<p>One final tweak I did: I disabled http compression. \u00a0Compression is great for servers running on the web, \u00a0where bandwidth is likely to be a bottleneck. On a home LAN, we have bandwidth to spare, but the server itself needs to conserve CPU. \u00a0Shutting 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 &#8220;compress.filetype&#8221;.<\/p>\n<h2>Results<\/h2>\n<p>So far things are pretty satisfactory with lighttpd &#8212; the server&#8217;s RAM usage has dropped significantly, and I believe we can now actually have more than one child using moodle at the same time \ud83d\ude42 ! \u00a0Have you had a good experience with Lighttpd? \u00a0Feel free to comment about it!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Our home server &#8212; we call him Rupert &#8212; is a real trooper. \u00a0Beneath 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. \u00a0On top of storing our files, caching our DNS requests, filtering the Web for little [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,21,5],"tags":[15,16,20,22,24,19],"class_list":["post-146","post","type-post","status-publish","format-standard","hentry","category-floss","category-old-computers-technology","category-technology","tag-debian","tag-floss-2","tag-how-to","tag-instructional","tag-my-computers","tag-old-computers"],"_links":{"self":[{"href":"https:\/\/alandmoore.com\/blog\/wp-json\/wp\/v2\/posts\/146","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/alandmoore.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/alandmoore.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/alandmoore.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/alandmoore.com\/blog\/wp-json\/wp\/v2\/comments?post=146"}],"version-history":[{"count":10,"href":"https:\/\/alandmoore.com\/blog\/wp-json\/wp\/v2\/posts\/146\/revisions"}],"predecessor-version":[{"id":156,"href":"https:\/\/alandmoore.com\/blog\/wp-json\/wp\/v2\/posts\/146\/revisions\/156"}],"wp:attachment":[{"href":"https:\/\/alandmoore.com\/blog\/wp-json\/wp\/v2\/media?parent=146"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alandmoore.com\/blog\/wp-json\/wp\/v2\/categories?post=146"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alandmoore.com\/blog\/wp-json\/wp\/v2\/tags?post=146"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}