
<?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>funkyHat &#124; Matt Wheeler &#124; Blog &#187; linux</title>
	<atom:link href="http://funkyhat.org/tag/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://funkyhat.org</link>
	<description>random, and less random, thoughts of Matt Wheeler</description>
	<lastBuildDate>Mon, 17 May 2010 22:13:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Drupal Multisite in lighttpd</title>
		<link>http://funkyhat.org/2010/02/18/drupal-multisite-in-lighttpd/</link>
		<comments>http://funkyhat.org/2010/02/18/drupal-multisite-in-lighttpd/#comments</comments>
		<pubDate>Thu, 18 Feb 2010 01:48:12 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[drupal]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[scripts]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://funkyhat.org/?p=42</guid>
		<description><![CDATA[I&#8217;m currently investigating switching from Apache to Lighttpd, and in the process I decided I&#8217;d have a go at simplifying my virtual host configuration. Lighttpd&#8217;s config files are already simpler than Apache&#8217;s, but I figured I could move from a separate config file for each virtual host to specifying settings in groups. Perhaps this is [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m currently investigating switching from Apache to Lighttpd, and in the process I decided I&#8217;d have a go at simplifying my virtual host configuration. Lighttpd&#8217;s config files are already simpler than Apache&#8217;s, but I figured I could move from a separate config file for each virtual host to specifying settings in groups. Perhaps this is also possible with Apache, but I&#8217;ve not tried as one file per vhost was working fine.</p>
<p>I also need more advanced URL rewriting than lighttpd&#8217;s mod_rewrite offers, as some Drupal modules rely on it (Apache has such URL rewriting inbuilt in its mod_rewrite). This part of the switch is simple, someone else has already done the hard work: installing lighttpd-mod-magnet and setting up <a title="http://groups.drupal.org/node/22787" href="http://groups.drupal.org/node/22787">this script</a> is all that needs to be done (instructions are in the script, near the top).</p>
<p>I wasn&#8217;t happy with either of the vhost modules provided by lighttpd, they appear to only work well if all of your sites are laid out in your filesystem in exactly the same way. I could have worked with that and created symlinks from my drupal dir to each site&#8217;s name in the vhost dir, but that feels messy, and would mean I could not set up access rules for the /sites directory.</p>
<p>Enter include_shell. This beautifully simple Lighttpd configuration option enables configuration to be generated by a script. My /etc/lighttpd/conf-available/15-drupal6.conf has one line:</p>
<pre>include_shell "/etc/lighttpd/shell/drupal6"
</pre>
<p>The drupal6 script is where the magic happens:</p>
<pre class="bash">#!/bin/sh
# Script for generating drupal multisite niceness

# Space separated list of disabled sites:
DISABLED=""

# Space separated list of sites with custom config files:
CUSTOM=""

# Location of custom config files:
CUSTOMDIR="/home/matt/Websites/testing/customconfig"

DRUPAL_DIR="/home/matt/Websites/testing/drupal6"
DRUPAL_LUA_PATH="/home/matt/Websites/tools/drupal/drupal.lua"

#Don't edit this, edit the other DISABLED="" VAR up there ^
DISABLED="all default "$DISABLED

for VHOST in `find ${DRUPAL_DIR}/sites/ -mindepth 1 -maxdepth 1  \( -type d -or -type l \) -exec basename "{}" \;` ; do
    for SITE in $DISABLED ; do
        if [ $SITE = $VHOST ]
        then
            #Just calling continue here can't work, we're inside a child loop
            DIS=y
        fi
     done

    if [ "$DIS" = "y" ]
    then
        DIS=""
        continue
    fi

    echo "\$HTTP[\"host\"] =~ \"$VHOST\" {
          var.vhost_name = \"$VHOST\"
          server.document-root = \"$DRUPAL_DIR\" 

          magnet.attract-physical-path-to = (\"${DRUPAL_LUA_PATH}\")

          \$HTTP[\"url\"] =~ \"^/sites/.*\" {
          \$HTTP[\"url\"] !~ \"^/sites/(`echo $VHOST| sed 's:\.:\\\.:g'`|all)/.*\" { url.access-deny = (\"\") }
          }"
          # This allows access to /sites/all and /sites/(this domain) which is all we need access to

    for SITE in $CUSTOM ; do
        if [ "$SITE" = "$VHOST" ]
        then
            cat $CUSTOMDIR/$SITE
        fi
    done

    echo "}"

done</pre>
<p>The variables in the script should be self explanatory, though the $CUSTOM variable is untested &#8211; it&#8217;s just there in case I have a need for it.</p>
<p>Lighttpd parses the output of the script as part of its configuration. As I&#8217;ve included a magnet configuration in each vhost using this script it&#8217;s not needed anywhere else (you just need to enable the magnet module).</p>
<p>This setup won&#8217;t work with drupal installations in subdirectories, but I don&#8217;t use subdirectories for my drupal sites, so that&#8217;s not an issue for me.</p>
<p>Hopefully others will find this useful ⢁)</p>
<p><strong>Update:</strong> I&#8217;ve replaced the alias lines with a url.access-deny statement, which actually works, with help from darix on irc.freenode.net/#lighttpd</p>
]]></content:encoded>
			<wfw:commentRss>http://funkyhat.org/2010/02/18/drupal-multisite-in-lighttpd/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Putting -rt kernels first in grub2</title>
		<link>http://funkyhat.org/2010/01/19/putting-rt-kernels-first-in-grub2/</link>
		<comments>http://funkyhat.org/2010/01/19/putting-rt-kernels-first-in-grub2/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 03:01:31 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://funkyhat.org/?p=36</guid>
		<description><![CDATA[I&#8217;ve installed the linux-rt realtime kernel package in Ubuntu 9.10 so I can play with the pro audio stuff that uses JACK properly. It seems that the -rt kernel doesn&#8217;t get as many updates as the -generic one, resulting in it having a lower release version (currently -generic is at 2.6.31-18 and -rt is at [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve installed the linux-rt realtime kernel package in Ubuntu 9.10 so I can play with the pro audio stuff that uses JACK properly. It seems that the -rt kernel doesn&#8217;t get as many updates as the -generic one, resulting in it having a lower release version (currently -generic is at 2.6.31-18 and -rt is at 2.6.31-9).</p>
<p>This is unfortunate because it means that -generic kernels will be placed first in the grub boot menu, and be chosen as the default boot option. I could change the default boot option each time a new kernel is installed, but I&#8217;m lazy.</p>
<p>There are a couple of solutions to this, firstly I could remove all of the linux-generic kernel versions, but I&#8217;d rather not just in case the -rt kernel causes issues, or some apps don&#8217;t play nice with it.</p>
<p>The other solution is to figure out how to re-order the grub menu. With grub2 (in Ubuntu and Debian at least) the menu config file should not be edited by hand, and is instead generated by running the scripts in /etc/grub.d/ in order. I didn&#8217;t work out exactly how the scripts order the kernels, but I figured out if I copied the file responsible for generating the linux entries in the boot list and modified my copy so that it only found -rt kernels I could force the -rt kernels to the top.</p>
<p>Here are the commands needed to do this:</p>
<pre>cd /etc/grub.d
sudo cp 10_linux 09_linux-rt
sudo sed -i 's:vmlinu[xz]-\*:vmlinu[xz]-*rt:' 09_linux-rt #&lt;-edits 09_linux-rt and makes
sudo update-grub                                          #  it only find -rt kernels
</pre>
<p>This does result in the -rt kernels being listed twice, and I could modify 10_linux as well so that this didn&#8217;t happen, but I&#8217;m happy with the way it is.</p>
]]></content:encoded>
			<wfw:commentRss>http://funkyhat.org/2010/01/19/putting-rt-kernels-first-in-grub2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
