$ cat /dev/brain > /dev/blog

Life is written in chapters but the table of contents is missing.


29 Nov

Wordpress on lighttpd: Rewrite rules with WP Super Cache and WPtouch


Screenshot blog.jeanpierre.de (WPtouch)As a few of my readers already know, this weblog is run by a Wordpress 2.x installation on a lighttpd web server (on top of a Debian Linux host). I have also installed, among others, the following plugins for Wordpress:

  • WP Super Cache — Serves a cached HTML version of Wordpress pages instead of serving each page as PHP output for every single request. This speeds up loading time and reduces the web server load. A lot!
  • WPtouch — When a user is using a mobile device, e.g., an iPhone, iPod touch, Android phone etc., they will see a slightly different layout of this blog, particularly optimized for small screen sizes.

lighttpd does not understand Apache’s RewriteRules that are used for permalinks in Wordpress. Therefore, you’ll have to come up with your own set of rewrite rules. Based on the rewrite.lua script initially written by Giovanni Intini, I have come up with a slightly modified version that takes the presence of the WPtouch plugin into account.

To install this script, perform the following steps:

  1. Download the latest version of the rewrite.lua script from my github project site.
  2. Place rewrite.lua in the root directory of your Wordpress installation, i.e., the same directory where you find the Wordpress PHP files such as wp-config.php.
  3. Update your lighttpd config file for the host running Wordpress and include this command:
    magnet.attract-physical-path-to = ( server.document-root + "/rewrite.lua" )1
  4. Make sure the Mobile device support option of the WP Super Cache plugin is enabled and the Rejected User Agents list is up-to-date. You’ll find those options in the Settings -> WP Super Cache menu of Wordpress once WP Super Cache has been activated.

The lighttpd host configuration should now look somewhat similar to this:

$HTTP["host"] == "myblog.com" {
server.document-root = “/srv/www/myblog/wordpress”
accesslog.filename = “/var/log/lighttpd/
myblog/access.log"
magnet.attract-physical-path-to = ( server.document-root + “/rewrite.lua” )
}

Restart lighttpd to put the changes in place. Check your error log for any strange entries. Check the WP Super Cache settings of your blog and try to view it from a mobile device or an iPhone simulator, e.g., iPhoney.

Let me know if you’d like to further improve the rewrite.lua code. Just go ahead, clone it from the github repository and start working on it! If you’re interested in writing your own LUA code check out the Programming in Lua book or the Programming in LUA website.

  1. This requires ModMagnet being set up for your lighttpd server. Follow the previous link if you need help installing it. []

17 Oct

Abmahnung wegen “Subscribe to comments”-Plugin


Die Deutschen sind ja bekanntermaßen ein äußerst klagefreudiges Völkchen. Und so verwundert es nicht, dass man sich also nicht nur der Höhe von Nachbars Hecke bei Gericht trifft sondern sich auch wegen eines Wordpress-Plugins (in diesem Fall das beliebte “Subscribe to comments”) eine Abmahnung einfängt.

Die Problematik “Newsletter/unerwünschte Werbung” sollte im Prinzip nur bei gewerblichen Angeboten gelten, doch die Definition ist nicht eindeutig. Manch Richter geht ja schon allein bei einer Schaltung von Anzeigen (z.B. Google Adsense o.ä.) zur Deckung der Hosting-Kosten von einer gewerblichen Tätigkeit aus.

Da ich weder Zeit noch Lust habe, an dieser Stelle Angriffsfläche für einen Rechtstreit zu bieten, ist das Plugin mit sofortiger Wirkung deaktiviert. Wordpress soll in Version 2.7 soll anscheinend mit einer (gesetzeskonformen) Double-Opt-In-Methode für Benachrichtigungen daher kommen. Ich bin gespannt.


29 Aug

lighttpd, xcache and Wordpress


It seems like I can bring the php-cgi processes of lighttpd to crash reproducibly when publishing a post in Wordpress :(

The description of this bug sounds very similar but I don’t even get to see a HTTP 500 error page after the PHP processes stall.


09 Jan

Problem mit Wordpress 2.0.6 und Feedburner


Seit dem Update auf Version 2.0.6 mag Feedburner meinen Feed von Zeit zu Zeit nicht mehr:

FeedBurner had trouble retrieving your Source Feed: […]
The error message is: “Your server disconnected us before sending the full source feed content.”

Das Problem liegt in der Behandlung von HTTP-Status-Werten, die beim Aufrufen des Feeds zurückgegeben werden.

Eine genauere Fehlerbeschreibung und Lösung/Patches gibt es (auf englisch) hier.

Leider ist auch in der neuen Version immer noch nicht das Problem behoben worden, dass die MySQL-Verbindung nicht äber UTF-8 läuft, was hässliche Zeichen statt Umlauten etc. zur Folge hat. Das lässt sich durch editieren der Datei wp-includes/wp_db.php in der Funktion wpdb() abstellen, man muss dort einfach direkt nach der Zeile

$this->dbh = @mysql_connect($dbhost, $dbuser, $dbpassword);

folgenden Befehl einfügen:

if ($this->dbh) {
  // Let this database connection use UTF-8 encoding
  $this->query("SET NAMES utf8");
}

Damit wird direkt nach erfolgtem Aufbauen der Verbindung zur Datenbank ein SQL-Befehl abgesetzt, um den Zeichensatz bei der MySQL-Verbindung festzulegen.