<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>Michael Gorven - cocooncrash</title>
  <link rel="alternate" type="text/html" href="http://michael.gorven.za.net/blog/2008/07/07/my-drupal-setup"/>
  <link rel="self" type="application/atom+xml" href="http://michael.gorven.za.net/node/27/atom/feed"/>
  <id>http://michael.gorven.za.net/node/27/atom/feed</id>
  <updated>2008-07-07T15:04:41+02:00</updated>
  <entry>
    <title>My Drupal setup</title>
    <link rel="alternate" type="text/html" href="http://michael.gorven.za.net/blog/2008/07/07/my-drupal-setup" />
    <id>http://michael.gorven.za.net/blog/2008/07/07/my-drupal-setup</id>
    <published>2008-07-07T15:04:41+02:00</published>
    <updated>2008-07-07T15:04:41+02:00</updated>
    <author>
      <name>mgorven</name>
    </author>
    <category term="drupal" />
    <category term="lighttpd" />
    <category term="lua" />
    <category term="openid" />
    <category term="technical" />
    <category term="yadis" />
    <summary type="html"><![CDATA[<p>Seeing that I've spent countless hours setting up my <a href="http://en.wikipedia.org/wiki/Drupal">Drupal</a> installation, I
thought that I would share this with others and document it for future
reference. Drupal is an extremely powerful <a href="http://en.wikipedia.org/wiki/Content_management_system"><abbr title="Content Management System">CMS</abbr></a> which can be used to create
a wide variety of sites. The disadvantage of this is that it requires a fair
amount of work to setup a straightforward blog, which involves installing and
configuring numerous modules.</p>

<h1>Installation</h1>

<p>Since there is no Ubuntu package for Drupal 6, I created my own package based
on the <span class="geshifilter"><code class="geshifilter-text">drupal5</code></span> one. I set it up as a virtual host in <a href="http://en.wikipedia.org/wiki/Lighttpd">Lighttpd</a> by simply
symlinking the domain name to <span class="geshifilter"><code class="geshifilter-text">/usr/share/drupal6</code></span>. I created a <a href="http://en.wikipedia.org/wiki/Mysql">MySQL</a>
database for the site and went through the Drupal install process. Since I'm
using a multi-site installation, I also needed to alias the <span class="geshifilter"><code class="geshifilter-text">/files</code></span> directory
for each site.</p>

<p><pre><div class="geshifilter"><pre class="geshifilter-text">$HTTP[&quot;host&quot;] == &quot;michael.gorven.za.net&quot; {
    alias.url = ( &quot;/files/&quot; =&amp;gt; &quot;/home/mgorven/public_html/&quot; )
}</pre></div></pre></p>

<h1>Clean URLs</h1>

<p>Clean URLs allows one to have URLs like <span class="geshifilter"><code class="geshifilter-text">/about</code></span> instead of
<span class="geshifilter"><code class="geshifilter-text">/index.php?q=about</code></span>. This however requires that the web server rewrites URLs
from the former to the latter. Drupal includes an <span class="geshifilter"><code class="geshifilter-text">htaccess</code></span> file containing
settings for <a href="http://en.wikipedia.org/wiki/Apache_HTTP_Server">Apache</a>, but not for Lighttpd. Lighttpd does have a rewrite
module, but it doesn't support the conditions that Drupal needs
(such as checking if a file exists).</p>

<p>Lighttpd does however have a module which allows one to add scripts to the
request process written in <a href="http://en.wikipedia.org/wiki/Lua_(programming_language)">Lua</a>. A script has already been
<a href="http://nordisch.org/2007/2/26/you-learn-something-new-every-day-today-lua-patterns">developed</a> which implements the required rewriting for Drupal. The following
lines in <span class="geshifilter"><code class="geshifilter-text">lighttpd.conf</code></span> enable this for a specified site (after
enabling <a href="http://trac.lighttpd.net/trac/wiki/Docs:ModMagnet">mod_magnet</a> and downloading the <a href="http://nordisch.org/drupal.lua">script</a>).</p>

<p><pre><div class="geshifilter"><pre class="geshifilter-text">$HTTP[&quot;host&quot;] == &quot;michael.gorven.za.net&quot; {
    index-file.names = ( &quot;index.php&quot; )
    magnet.attract-physical-path-to = ( &quot;/etc/lighttpd/drupal.lua&quot; )
}</pre></div></pre></p>

<h1>Blog</h1>

<p>When Drupal is first installed, there is no mention of blogging as such. The
first step is to enable the <em>Blog</em> core module<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup>. This creates a <em>blog</em>
content type and enables a blog for each user. (The module is designed for a
multi-user blog, but can be used for a single user as well.) However, this
doesn't give you all the functionality you expect from a blog engine.</p>

<p>Tagging is handled by the <em>Taxonomy</em> core module. You first need to create a
vocabulary though, and enable it for blog posts. (This took me ages to
discover.) In order to get nice URLs (including the date and post title, for
example) you need to install the <a href="http://drupal.org/project/pathauto">Pathauto</a> module and configure a pattern for
blog posts. You may also want to define a pattern for tags.</p>

<p>There is also no archive functionality. The best way that I can find is the
<a href="http://drupal.org/project/views">Views</a> module. It includes a pre-defined "archive" view which can display
posts from a specific month, and links to the monthly pages. Even after much
investigation I couldn't get the archive to behave like typical blog archives
(i.e. <span class="geshifilter"><code class="geshifilter-text">/blog/2008/07/07</code></span>, <span class="geshifilter"><code class="geshifilter-text">/blog/2008/07</code></span> and <span class="geshifilter"><code class="geshifilter-text">/blog/2008</code></span> for daily, monthly
and yearly archives respectively).</p>

<h1>Other Blog Features</h1>

<p>The <a href="http://drupal.org/project/trackback">Trackback</a> and <a href="http://drupal.org/project/pingback">Pingback</a> modules implement automatic linking with
other blogs. (I haven't actually tested these yet.) The <em>Blog API</em> core  module
allows the blog to be managed with external clients. The
<a href="http://drupal.org/project/markdown">Markdown</a> module allows you to write posts using <a href="http://daringfireball.net/projects/markdown/">Markdown</a>
syntax instead of HTML.</p>

<h1>Comments</h1>

<p>Drupal enables comments for blog posts by default. The <a href="http://drupal.org/project/akismet">Akismet</a>
module implements spam filtering using the <a href="http://akismet.com/">Akismet</a> service. The
<a href="http://drupal.org/project/captcha">CAPTCHA</a> and <a href="http://drupal.org/project/recaptcha">reCAPTCHA</a> modules allows you to require users to answer
a <a href="http://recaptcha.net/">reCAPTCHA</a> when submitting comments. (I haven't actually enabled <a href="http://en.wikipedia.org/wiki/Captcha">CAPTCHAs</a> 
since I haven't gotten any comment spam yet. Or real comments for that
matter...)</p>

<h1>Posting by email</h1>

<p>The <a href="http://drupal.org/project/mailhandler">Mailhandler</a> module allows you to submit posts via email. The
configuration is fairly straightforward, except for the available commands which
can be found <a href="http://drupal.org/node/38943">here</a>. These can be specified at the beginning of
emails and in the configuration as defaults. I use the following commands.</p>

<p><pre><div class="geshifilter"><pre class="geshifilter-text">type: blog
taxonomy: [mail]
promote: 1
status: 1
comment: 2</pre></div></pre></p>

<p>This creates blog posts and tags them with the "mail" tag. Posts are published
and promoted to the front page, and comments are enabled.</p>

<p>The one thing it doesn't handle is attachments (such as images). There are a
couple of modules<sup id="fnref:2"><a href="#fn:2" rel="footnote">2</a></sup> which support this, but they aren't available for Drupal 6
yet. (<a href="http://vhata.net/">Vhata</a> has also hacked together a <a href="http://vhata.net/blog/2008/04/26/phoblogging">photo blogging</a> system, but
this isn't implemented as a Drupal module.) I don't really need this feature, so
I'm going to wait until these modules are updated.</p>

<h1>OpenID</h1>

<p>The <a href="http://drupal.org/project/openid">OpenID</a> module allows you to log into your site using
<a href="http://en.wikipedia.org/wiki/Openid">OpenID</a>. The <a href="http://drupal.org/project/openidurl">OpenID URL</a> module allows you to delegate your
Drupal site as an OpenID by specifying your provider and/or your <a href="http://en.wikipedia.org/wiki/Yadis">Yadis</a>
document.</p>

<h2>Yadis Advertisement</h2>

<p>Yadis documents are advertised with a <span class="geshifilter"><code class="geshifilter-text">meta</code></span> header in the HTML document, but
this isn't the ideal method of doing so since the relaying party needs to
download the entire HTML file. The <a href="http://intertwingly.net/blog/2007/01/03/OpenID-for-non-SuperUsers">preferred methods</a> are to
insert an <span class="geshifilter"><code class="geshifilter-text">X-XRDS-Location</code></span> in the HTTP headers, or to automatically serve the
Yadis document if the user agent specifies <span class="geshifilter"><code class="geshifilter-text">application/xrds+xml</code></span> in the
<span class="geshifilter"><code class="geshifilter-text">Accept</code></span> header.</p>

<p>The former method can be accomplished with the <span class="geshifilter"><code class="geshifilter-text">setenv</code></span> module for Lighttpd. The
second is essentially a conditional rewrite, and so requires some Lua scripting
again. The following script will do the job.</p>

<p><pre><div class="geshifilter"><pre class="geshifilter-text">if lighty.request[&quot;Accept&quot;] == &quot;application/xrds+xml&quot; then
    lighty.env[&quot;uri.path&quot;] = &quot;/files/yadis.xrdf&quot;
end</pre></div></pre></p>

<p>The following lines in <span class="geshifilter"><code class="geshifilter-text">lighttpd.conf</code></span> will announce the Yadis document for the
root URL.</p>

<p><pre><div class="geshifilter"><pre class="geshifilter-text">$HTTP[&quot;url&quot;] == &quot;/&quot; {
    magnet.attract-raw-url-to = ( &quot;/etc/lighttpd/yadis.lua&quot; )
    setenv.add-response-header = ( &quot;X-XRDS-Location&quot; =&amp;gt; &quot;http://michael.gorven.za.net/files/yadis.xrdf&quot; )
}</pre></div></pre></p>

<h1>Random Stuff</h1>

<p>The tag block is generated by the <a href="http://drupal.org/project/tagadelic">Tagadelic</a> module. The "Recent Tracks"
block is generated from my <a href="http://www.last.fm/">LastFM</a> feed by the <em>Aggregator</em> core module, and
the list of networks is simply a custom block. The <a href="http://en.wikipedia.org/wiki/Atom_(standard)">Atom</a> feed is generated by
the <a href="http://drupal.org/project/atom">Atom</a> module. The contact form, search and file upload are all
core modules.</p>

<h1>Missing Stuff</h1>

<p>The one thing I haven't sorted out is image handling. There are a couple ways to <a href="http://groups.drupal.org/node/5328">handle images</a> in Drupal, but none of these appeal to me (they're too complicated). I will probably just upload images as attachments and insert them manually in the body.</p>

<div class="footnotes">
<hr />
<ol>

<li id="fn:1">
<p>It is however possible to run a blog without the <em>Blog</em> module.&#160;<a href="#fnref:1" rev="footnote">&#8617;</a></p>
</li>

<li id="fn:2">
<p><a href="http://drupal.org/project/mailsave">Mailsave</a> and <a href="http://drupal.org/project/mmb">Mobile Media Blog</a>.&#160;<a href="#fnref:2" rev="footnote">&#8617;</a></p>
</li>

</ol>
</div>
    ]]></summary>
    <content type="html"><![CDATA[<p>Seeing that I've spent countless hours setting up my <a href="http://en.wikipedia.org/wiki/Drupal">Drupal</a> installation, I
thought that I would share this with others and document it for future
reference. Drupal is an extremely powerful <a href="http://en.wikipedia.org/wiki/Content_management_system"><abbr title="Content Management System">CMS</abbr></a> which can be used to create
a wide variety of sites. The disadvantage of this is that it requires a fair
amount of work to setup a straightforward blog, which involves installing and
configuring numerous modules.</p>

<h1>Installation</h1>

<p>Since there is no Ubuntu package for Drupal 6, I created my own package based
on the <code>drupal5</code> one. I set it up as a virtual host in <a href="http://en.wikipedia.org/wiki/Lighttpd">Lighttpd</a> by simply
symlinking the domain name to <code>/usr/share/drupal6</code>. I created a <a href="http://en.wikipedia.org/wiki/Mysql">MySQL</a>
database for the site and went through the Drupal install process. Since I'm
using a multi-site installation, I also needed to alias the <code>/files</code> directory
for each site.</p>

<pre><code>$HTTP["host"] == "michael.gorven.za.net" {
    alias.url = ( "/files/" =&gt; "/home/mgorven/public_html/" )
}
</code></pre>

<h1>Clean URLs</h1>

<p>Clean URLs allows one to have URLs like <code>/about</code> instead of
<code>/index.php?q=about</code>. This however requires that the web server rewrites URLs
from the former to the latter. Drupal includes an <code>htaccess</code> file containing
settings for <a href="http://en.wikipedia.org/wiki/Apache_HTTP_Server">Apache</a>, but not for Lighttpd. Lighttpd does have a rewrite
module, but it doesn't support the conditions that Drupal needs
(such as checking if a file exists).</p>

<p>Lighttpd does however have a module which allows one to add scripts to the
request process written in <a href="http://en.wikipedia.org/wiki/Lua_(programming_language)">Lua</a>. A script has already been
<a href="http://nordisch.org/2007/2/26/you-learn-something-new-every-day-today-lua-patterns">developed</a> which implements the required rewriting for Drupal. The following
lines in <code>lighttpd.conf</code> enable this for a specified site (after
enabling <a href="http://trac.lighttpd.net/trac/wiki/Docs:ModMagnet">mod_magnet</a> and downloading the <a href="http://nordisch.org/drupal.lua">script</a>).</p>

<pre><code>$HTTP["host"] == "michael.gorven.za.net" {
    index-file.names = ( "index.php" )
    magnet.attract-physical-path-to = ( "/etc/lighttpd/drupal.lua" )
}
</code></pre>

<h1>Blog</h1>

<p>When Drupal is first installed, there is no mention of blogging as such. The
first step is to enable the <em>Blog</em> core module<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup>. This creates a <em>blog</em>
content type and enables a blog for each user. (The module is designed for a
multi-user blog, but can be used for a single user as well.) However, this
doesn't give you all the functionality you expect from a blog engine.</p>

<p>Tagging is handled by the <em>Taxonomy</em> core module. You first need to create a
vocabulary though, and enable it for blog posts. (This took me ages to
discover.) In order to get nice URLs (including the date and post title, for
example) you need to install the <a href="http://drupal.org/project/pathauto">Pathauto</a> module and configure a pattern for
blog posts. You may also want to define a pattern for tags.</p>

<p>There is also no archive functionality. The best way that I can find is the
<a href="http://drupal.org/project/views">Views</a> module. It includes a pre-defined "archive" view which can display
posts from a specific month, and links to the monthly pages. Even after much
investigation I couldn't get the archive to behave like typical blog archives
(i.e. <code>/blog/2008/07/07</code>, <code>/blog/2008/07</code> and <code>/blog/2008</code> for daily, monthly
and yearly archives respectively).</p>

<h1>Other Blog Features</h1>

<p>The <a href="http://drupal.org/project/trackback">Trackback</a> and <a href="http://drupal.org/project/pingback">Pingback</a> modules implement automatic linking with
other blogs. (I haven't actually tested these yet.) The <em>Blog API</em> core  module
allows the blog to be managed with external clients. The
<a href="http://drupal.org/project/markdown">Markdown</a> module allows you to write posts using <a href="http://daringfireball.net/projects/markdown/">Markdown</a>
syntax instead of HTML.</p>

<h1>Comments</h1>

<p>Drupal enables comments for blog posts by default. The <a href="http://drupal.org/project/akismet">Akismet</a>
module implements spam filtering using the <a href="http://akismet.com/">Akismet</a> service. The
<a href="http://drupal.org/project/captcha">CAPTCHA</a> and <a href="http://drupal.org/project/recaptcha">reCAPTCHA</a> modules allows you to require users to answer
a <a href="http://recaptcha.net/">reCAPTCHA</a> when submitting comments. (I haven't actually enabled <a href="http://en.wikipedia.org/wiki/Captcha">CAPTCHAs</a> 
since I haven't gotten any comment spam yet. Or real comments for that
matter...)</p>

<h1>Posting by email</h1>

<p>The <a href="http://drupal.org/project/mailhandler">Mailhandler</a> module allows you to submit posts via email. The
configuration is fairly straightforward, except for the available commands which
can be found <a href="http://drupal.org/node/38943">here</a>. These can be specified at the beginning of
emails and in the configuration as defaults. I use the following commands.</p>

<pre><code>type: blog
taxonomy: [mail]
promote: 1
status: 1
comment: 2
</code></pre>

<p>This creates blog posts and tags them with the "mail" tag. Posts are published
and promoted to the front page, and comments are enabled.</p>

<p>The one thing it doesn't handle is attachments (such as images). There are a
couple of modules<sup id="fnref:2"><a href="#fn:2" rel="footnote">2</a></sup> which support this, but they aren't available for Drupal 6
yet. (<a href="http://vhata.net/">Vhata</a> has also hacked together a <a href="http://vhata.net/blog/2008/04/26/phoblogging">photo blogging</a> system, but
this isn't implemented as a Drupal module.) I don't really need this feature, so
I'm going to wait until these modules are updated.</p>

<h1>OpenID</h1>

<p>The <a href="http://drupal.org/project/openid">OpenID</a> module allows you to log into your site using
<a href="http://en.wikipedia.org/wiki/Openid">OpenID</a>. The <a href="http://drupal.org/project/openidurl">OpenID URL</a> module allows you to delegate your
Drupal site as an OpenID by specifying your provider and/or your <a href="http://en.wikipedia.org/wiki/Yadis">Yadis</a>
document.</p>

<h2>Yadis Advertisement</h2>

<p>Yadis documents are advertised with a <code>meta</code> header in the HTML document, but
this isn't the ideal method of doing so since the relaying party needs to
download the entire HTML file. The <a href="http://intertwingly.net/blog/2007/01/03/OpenID-for-non-SuperUsers">preferred methods</a> are to
insert an <code>X-XRDS-Location</code> in the HTTP headers, or to automatically serve the
Yadis document if the user agent specifies <code>application/xrds+xml</code> in the
<code>Accept</code> header.</p>

<p>The former method can be accomplished with the <code>setenv</code> module for Lighttpd. The
second is essentially a conditional rewrite, and so requires some Lua scripting
again. The following script will do the job.</p>

<pre><code>if lighty.request["Accept"] == "application/xrds+xml" then
    lighty.env["uri.path"] = "/files/yadis.xrdf"
end
</code></pre>

<p>The following lines in <code>lighttpd.conf</code> will announce the Yadis document for the
root URL.</p>

<pre><code>$HTTP["url"] == "/" {
    magnet.attract-raw-url-to = ( "/etc/lighttpd/yadis.lua" )
    setenv.add-response-header = ( "X-XRDS-Location" =&gt; "http://michael.gorven.za.net/files/yadis.xrdf" )
}
</code></pre>

<h1>Random Stuff</h1>

<p>The tag block is generated by the <a href="http://drupal.org/project/tagadelic">Tagadelic</a> module. The "Recent Tracks"
block is generated from my <a href="http://www.last.fm/">LastFM</a> feed by the <em>Aggregator</em> core module, and
the list of networks is simply a custom block. The <a href="http://en.wikipedia.org/wiki/Atom_(standard)">Atom</a> feed is generated by
the <a href="http://drupal.org/project/atom">Atom</a> module. The contact form, search and file upload are all
core modules.</p>

<h1>Missing Stuff</h1>

<p>The one thing I haven't sorted out is image handling. There are a couple ways to <a href="http://groups.drupal.org/node/5328">handle images</a> in Drupal, but none of these appeal to me (they're too complicated). I will probably just upload images as attachments and insert them manually in the body.</p>

<div class="footnotes">
<hr />
<ol>

<li id="fn:1">
<p>It is however possible to run a blog without the <em>Blog</em> module.&#160;<a href="#fnref:1" rev="footnote">&#8617;</a></p>
</li>

<li id="fn:2">
<p><a href="http://drupal.org/project/mailsave">Mailsave</a> and <a href="http://drupal.org/project/mmb">Mobile Media Blog</a>.&#160;<a href="#fnref:2" rev="footnote">&#8617;</a></p>
</li>

</ol>
</div>
    ]]></content>
  </entry>
</feed>
