<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Luke Maurits &#187; lighttpd</title>
	<atom:link href="http://luke.maurits.id.au/blog/tag/lighttpd/feed/" rel="self" type="application/rss+xml" />
	<link>http://luke.maurits.id.au</link>
	<description>Assorted geekery</description>
	<lastBuildDate>Sun, 06 Mar 2011 06:52:47 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Pyblosxom now running as FastCGI via flup</title>
		<link>http://luke.maurits.id.au/blog/2008/08/pyblosxom-now-running-as-fastcgi-via-flup/</link>
		<comments>http://luke.maurits.id.au/blog/2008/08/pyblosxom-now-running-as-fastcgi-via-flup/#comments</comments>
		<pubDate>Fri, 08 Aug 2008 12:42:00 +0000</pubDate>
		<dc:creator>Luke Maurits</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[flup]]></category>
		<category><![CDATA[lighttpd]]></category>
		<category><![CDATA[pyblosxom]]></category>
		<category><![CDATA[web technology]]></category>

		<guid isPermaLink="false">http://luke.maurits.id.au/blog/2008/08/pyblosxom-now-running-as-fastcgi-via-flup/</guid>
		<description><![CDATA[As I suggested I might a few months back, I have recently got around to running this Pyblosxom blog as a FastCGI process.  The increase in speed is really impressive.  Unless you happen to visit during a particularly busy period, the first time you hit this site a persistent Pyblosxom process will be [...]]]></description>
			<content:encoded><![CDATA[<p>As I <a href="http://luke.maurits.id.au/blog/2008/04/commenting-feature-added-pyblosxom-headaches/">suggested I might</a> a few months back, I have recently got around to running this <a href="http://pyblosxom.sourceforge.net">Pyblosxom</a> blog as a <a href="www.fastcgi.com">FastCGI</a> process.  The increase in speed is really impressive.  Unless you happen to visit during a particularly busy period, the first time you hit this site a persistent Pyblosxom process will be started and will then hang around to service your subsequent requests, making them nice and speedy.  This is made possible with Allan Saddi&#8217;s <a href="http://trac.saddi.com/flup">flup library</a>, which lets Python <a href="http://www.wsgi.org">WSGI</a> applications talk to webservers via FastCGI or SCGI.  I&#8217;ll go through the details of my setup (which uses <a href="http://www.lighttpd.net">lighttpd</a> as its webserver) for the sake of other people who want to do the same</p>
<p>There are basically two steps involved:  writing a FastCGI script which wraps the Pyblosxom WSGI app up in flup, and then configuring lighttpd to map a given URL to this script.</p>
<p>Here&#8217;s my FastCGI script (with modified paths):</p>
<pre><code> #!/usr/pkg/bin/python2.4
import sys
import Pyblosxom.pyblosxom
from flup.server.fcgi import WSGIServer

sys.path.insert(0, "/path/to/pyblosxom_config_file")
sys.path.insert(0, "/path/to/pyblosxom/codebase")
app = Pyblosxom.pyblosxom.PyBlosxomWSGIApp()
WSGIServer(app).run()
</code></pre>
<p>Pay attention to the shebang line: <tt>/usr/pkg/bin/python2.4</tt> will only work on NetBSD systems.  <tt>/usr/bin/env python</tt> should work anywhere and is better form in general.  The second call to <tt>sys.path.insert</tt> is only necessary if you have Pyblosxom itself sitting around in a directory somewhere rather than installed as a Python library in the <tt>site-packages</tt> directory.  All if this is discussed on the Pyblosxom page <a href="http://pyblosxom.sourceforge.net/1.4/manual/install_wsgi.html">here</a>, where they write a more or less identical script, minus the use of <tt>flup.server.fcgi.WSGIServer</tt>.</p>
<p>Here&#8217;s the relevant part of my lighttpd.conf:</p>
<pre><code>$HTTP["host"] == "www.luke.maurits.id.au" {
        fastcgi.server = (
                "/blog" =&gt; (
                        "script.fcgi" =&gt; (
                                "bin-path"              =&gt; "/path/to/fastcgiscript.py",
                                "socket"                =&gt; "/tmp/pyblosxom.sock",
                                "check-local"   	=&gt; "disable",
                                "disable-time"          =&gt; 1,
                                "min-procs"             =&gt; 1,
                                "max-procs"             =&gt; 32,
                                "max-load-per-proc"     =&gt; 4,
                                "idle-timeout"          =&gt; 60
                        ),
                ),
        )
}
</code></pre>
<p>This maps the URI <tt>/blog</tt> on the <tt>www.luke.maurits.id.au</tt> virtual host to to the script we wrote above.  When a request for that URI hits the server, lighttpd will run the script and talk to it through the unix domain socket specified (<tt>/tmp/pyblosxom.sock</tt> in this case).  Make sure that, wherever you choose to put your socket, your webserver has read and write permissions.  Note also that the path should be relative to any directory that you have lighttpd set to <tt>chroot</tt> into.  This instance of the script will die after 60 seconds (&#8220;<tt>idle-timeout</tt>&#8221; above) pass without any requests coming in.  Extra instances will be run, up to 32 (&#8220;<tt>max-procs</tt>&#8220;) in total, to accommodate heavy load.  A new process is created when ever there becomes more than 4 (&#8220;<tt>max-load-per-proc</tt>&#8220;) queued requests for each existing process.</p>
<p>As I mentioned, this set up is very noticeably faster than running Pyblosxom as a plain CGI process &#8211; as one would fully expect.  So far I have had a few problems where a huge number of FastCGI script processes are spawned for no apparent reason, slowing the server to a crawl and resulting in timeouts.  I&#8217;m not sure what has caused these, though logic dictates it must be a problem with lighttpd.  These seem to be over, but if they persist I will have to look into getting something other than lighttpd to span the FastCGI processes.  Hopefully this won&#8217;t happen.  Until it does, enjoy the faster browsing!</p>
]]></content:encoded>
			<wfw:commentRss>http://luke.maurits.id.au/blog/2008/08/pyblosxom-now-running-as-fastcgi-via-flup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lighttpd and new feedformatter</title>
		<link>http://luke.maurits.id.au/blog/2008/03/lighttpd-and-new-feedformatter/</link>
		<comments>http://luke.maurits.id.au/blog/2008/03/lighttpd-and-new-feedformatter/#comments</comments>
		<pubDate>Sun, 02 Mar 2008 15:18:00 +0000</pubDate>
		<dc:creator>Luke Maurits</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[feedformatter]]></category>
		<category><![CDATA[lighttpd]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://luke.maurits.id.au/blog/2008/03/lighttpd-and-new-feedformatter/</guid>
		<description><![CDATA[Last night I replaced the Apache 1.3.x webserver which had been hosting this site with lighttpd (pronounced &#8220;lighty&#8221;), a very small, light and fast webserver which emphasises the use of FastCGI to overcome the limitations of traditional CGI, instead of embedding language interpreters in the server.  This is a view point that I approve [...]]]></description>
			<content:encoded><![CDATA[<p>Last night I replaced the Apache 1.3.x webserver which had been hosting this site with <a href="http://www.lighttpd.net">lighttpd</a> (pronounced &#8220;lighty&#8221;), a very small, light and fast webserver which emphasises the use of FastCGI to overcome the limitations of traditional CGI, instead of embedding language interpreters in the server.  This is a view point that I approve of, for reasons of security and freedom of choice in server/language pairings.  I&#8217;ve actually tried switching to lighty before, but ended up not because I couldn&#8217;t get PHP working with FastCGI (a requirement for my <a href="http://www.tombsaver.org">TombSaver</a> page).  It turns out if I&#8217;d read the <tt>MESSAGE</tt> that pkgsrc shows after you install php I almost certainly would have, but oh well.  It&#8217;s done now and I&#8217;m happy with the change.</p>
<p>I&#8217;ve also released a new version of <a href="/software/feedformatter/">feedformatter</a> &#8211; already!  I am taking the &#8220;release early, release often&#8221; idea to quite an extreme with this latest project (normally I wouldn&#8217;t release anything in the state that feedparser 0.1 and 0.2 have been).  Realistically, this is no big problem &#8211; in all probability nobody has even used 0.1 yet anyway.  The new version includes &#8220;pretty printing&#8221; of feeds (with newlines and indentation), a first stab at some compatibility with the <a href="http://www.feedparser.org">Universal Feed Parser</a>, better feed validation (though there is still a long way to go on this front) and slightly tidier code.</p>
<p>Yes, there probably will be a 0.3 release in the next day or two.</p>
]]></content:encoded>
			<wfw:commentRss>http://luke.maurits.id.au/blog/2008/03/lighttpd-and-new-feedformatter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

