Using the Raspberry Pi as a web server

Ever since I got my Model B Raspberry Pi board a few weeks ago, I wanted to use it as an inexpensive web server. So here it is. In fact, you are reading this very post delivered straight from my Pi.

I used the latest Raspbian image (Debian Wheezy/Testing), and installed lighttpd 1.4.31, php 5.4.4 and mysql 5.5.24 straight from the Debian repositories. Linking up lighttpd with the PHP interpreter using FastCGI was very simple:

sudo apt-get install php5-common php5-cgi php5 php5-mysql
sudo lighty-enable-mod fastcgi-php

Then, I followed the steps outlined in this answer on Server Fault to set up a named vhost in lighttpd. There were other methods on various websites regarding mod_simple_vhost but since I didn’t need a dynamic setup based on the name of each virtual host, a simpler setup like the example in the Server Fault answer worked for me.

After that, I followed the regular WordPress installation procedure. Who knew $35 could get you a decent web server?

Initially, I had concerns about the performance of the Pi and whether it would be able to take up the load of a full WordPress website with MySQL and all. While obviously you wouldn’t want to run a high-traffic website on low-performance hardware like this :) , it does the job for any very-low-traffic web site, and I’m quite surprised at how much performance it can deliver for the amount of power it consumes.

 

Who woulda thunk you could serve website pies?

So there you have it. I’ll be running this blog on the Pi for the next few weeks. Let’s see how it goes; it’s going to be a hell of an experiment. Or, probably a very good idea.

   

11 thoughts on “Using the Raspberry Pi as a web server

  1. costales

    Yes, I’m really happy too with my Raspberry as cheap server.
    My recommendation is: Add an external hard disk, move your apache files & mysql database to it, you will win speed. You can remove the SD swap file (just remove dphys-swapfile package) and create another in the external hard disk. Remove the extra ttys too. With these tips, you will improve the speed a lot and you will have a better storage than a SD :)
    I miss just one thing in my Raspberry: Ubuntu :P
    Best regards.

    Reply
    1. bilal Post author

      Thanks for the suggestion. But is USB 2.0 really faster than the SD card interface? I doubt if it would be worth the effort, though I sure will give it a shot.

      Also, I miss Ubuntu too, but Debian on the Pi is stable already and is like 99% of Ubuntu.

      Reply
  2. Jeremy Bicha

    I just stumbled across this yesterday. Amos Blanton, the online community coordinator for Scratch, hosts his blog on a Raspberry Pi. He uses a static HTML generator though instead of WordPress.

    Reply
    1. bilal Post author

      Right. That would free up even more resources, CPU cycles and memory. I’ll stick to WordPress since it’s performing decently for now, and if performance does become a concern due to higher traffic, I’ll consider a switch.

      Reply
  3. th0rgall

    Hey, thats nice! I’m buying myself a Raspi B anyway, but do you think that the Pi is also capable of serving other things alongside a simple webserver?

    For example, I’m now running an apache webserver with phpbb3 & umurmur (minimalistic derivate of Murmur, Mumble (voice chat) server) on a 1.2 GHz NAS with 256mb ram, without any problems, but that’s also on another architecture.

    It would be awesome if I could free this noisy NAS from a 24/7 uptime by replacing it with a silent, power- & cost efficiënt Raspi :) .

    Reply

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>