Raspberry Pi Webserver

My Raspberry Pi finally arrived a couple weeks ago and I’ve been fooling around with it ever since. I’m not a “real” programmer or particularly skilled sysadmin so I’ve mainly been trying out different bits of software, screwing something up, flashing a new OS image and diving back in. My first project was setting up a webserver.

At Convoy, my print and web design company, we create all of our sites in WordPress. So naturally I wanted to see see if the RasPi could handle a WordPress site. The short answer is, yes it can. But the problem is, a typical WordPress hosting environment, including Apache, MySQL, and PHP requires so much memory that that’s very little left over for handling anything more that light traffic.

So – how can one lighten the memory requirements for WordPress hosting? There are a variety of ways to go about it…

Replace Apache with Nginx

Apache is what they call a Heavy webserver. It spawns several processes to handle concurrent requests. Each process contains a full running copy of PHP and its extensions. It’s a powerful piece of software but it does not scale well. Naturally, when software gets bloated, other teams step in to offer lighter alternatives. Nginx is the current favorite.

The problem with Nginx is that it doesn’t support .htaccess files, and WordPress relies on them for it’s readable and search-engine-friendly URLs. Redirects can still be configured, it’s just a different process. And the non-standard system means that plugins that rely on custom .htaccess rules will need to be configured by hand rather than Just Working.

Replace MySQL with SQLite

MySQL is also a bit heavy. Maybe not compared to it’s Enterprise-grade alternatives like Oracle and Microsoft SQL Server, but when you’ve got 224 MB to work with, any robust database will be feeling the pinch. SQLite, on the other hand, writes it’s database info directly to flat files and has the added, ahem, advantage of having no security, so there are no user accounts to configure. And you can back it up simply by copying the files off your server via FTP.

Does WordPress work with SQLite? The answer is a qualified yes. There’s a WordPress plugin that allows you to use other databases for the back end via the PDO database abstraction layer, which SQLite supports. But it’s not that easy because it has to be installed before WordPress itself is installed, since your Pi won’t have MySQL available, and WordPress is built for MySQL by default.

Also disturbing is that the plugin hasn’t been updated since early 2010, which does not suggest that the author is maintaining it anymore.

If you want to try it, there’s a prepackaged WordPress with PDO plugin available for download. Since there’s no MySQL to configure, copy the files over to your Pi and you’re done. Comments on the board suggest that the prepackaged installation can then be upgraded to the latest version of WordPress and everything keeps on working.

The Middle Road – Tightening Your Software’s Belt

Sometimes the best solution is a combination of ideas. I did not want to get bogged down in an endless stream of esoteric performance tuning options, so I went looking for someone who had been down the road before me. As it turns out, the prevalence of cheap virtual servers with impossibly low memory configurations has inspired many before me to wring the most performance possible out of a meager 256MB. If didn’t take me long to find this article on lowendbox.com.

Not only has the author crushed a working installation of Nginx, MySQL, and PHP down to Lilliputian proportions, he’s provided a handy shell script to install and configure the packages for you. The script will even download the latest WordPress and set it up, and it works with multiple installations.

Now if I was really devoted, I’d set up a perfectly tuned webserver with a demo WordPress site, create an image, zip it up, and make it available here for download. That’s the beauty of Raspberry Pi. Once you’ve got a great setup, configured to your exacting specifications, it’s easy to share it with the rest of the RasPi community without having to worry about people with slightly different hardware configurations complaining that it doesn’t work. And with SD cards so cheap (I bought three 8GB cards for $6 each earlier this week) anyone with a Pi can swap cards around and work on several projects at once. Personally I’m waiting for an enterprising individual to package a MAME emulator, a tall stack of games, and a tuned up Raspbian install and distribute the ultimate Arcade-In-A-Box.

The Fatal Flaw of the Raspberry Pi Webserver

If the RasPi has the chops to run a decent webserver, why aren’t I running this site on one? It’s simple – webservers have to be up and running all the time to be useful. I’ve only got a single Raspberry Pi computer, and I’m not willing to dedicate it to a single purpose just yet. Maybe when I’ve got a few lying around I’ll change my tune. But for now, I’ve got to get Quake 3 running!

Posted in Raspberry Pi
3 comments on “Raspberry Pi Webserver
  1. Leif says:

    Serious s*it this is awesome! Gonna try it once I get my hands on the RPi. Thanks for the share!

  2. online games says:

    Fantastic blog you have here but I was wanting to know if you knew of any message boards
    that cover the same topics discussed in this article?

    I’d really love to be a part of online community where I can get suggestions from other experienced people that share the same interest.
    If you have any suggestions, please let me know. Thank you!

  3. Raspberry Pi says:

    Keepp on writing, ɡreat job!

Leave a Reply

Your email address will not be published. Required fields are marked *