WordPress on Raspberry Pi

WordPress on Raspberry Pi

WordPress is a software that allows users to create nice, content-rich websites or blogs. It is a very popular, widely used, free, open-source content management system. What makes it well organized, and yet flexible, is that it combines a template-based approach with a plug-in system which can extend the basic framework with virtually limitless functionality.

However, WordPress is only the software used to create and manage the content, in order to really have an online, functioning website, it needs to be hosted on a server. This is where the question pops up: what is the best place to host a WordPress site? There are mainly three answers to this question, three alternatives, each one with its advantages and disadvantages:

  1. The most common place to host a WordPress website/blog is wordpress.com. The great thing about this option is that it’s free and that the hosting is fully integrated with the WordPress software, which means that you can just sign up and get a WordPress website up and running in a matter of a few clicks. What is not so great about it that if you choose this option, the flexibility of the WordPress software will be restricted by the fact that on wordpress.com you can only use a few templates that they offer. That may not sound so bad, but it is. The functionality of WordPress software greatly depends on what the used template can do, so if you have more a less advanced template, you won’t be able to do so much. It will very soon become frustrating that you cannot customize many things and that some creation tools are not available. There are more advanced templates that you can buy from wordpress.com, but you still won’t have the freedom to do anything you like.
  2. Another option is to just download the free WordPress software and host your site on a rented server by purchasing a hosting package from some company. Hosting services are relatively cheap nowadays and if you choose a good one your site will most likely be hosted on ultra-fast computers, which will guarantee good performance. Performance actually is an important factor in case of WordPress because the system can be quite heavy and can require some powerful hardware in order to deliver a smooth user experience. Using a hosting service will also guarantee that your website will have minimum downtime and the data will never be lost because of, say, damaged hardware. Most hosting services will have all the required other software installed which is needed by WordPress to run and you will be able to customize your site freely by using any template you can get (and there are many good ones out there, even for free). A not so significant disadvantage can be that you will not be able to use quite any tools to configure your server, to upload content to it, etc. You will be limited to what the hosting company uses.
  3. The third and most flexible option is to host your WordPress site on your own server. The hardware and the software will both fully belong to you and you’ll both have them at hand all the time, so you can do with them anything that crosses your mind at any time. Of course, this introduces problems like making sure you have a static IP address, a speedy enough internet connection, which is always up, a server machine which is running all the time and doesn’t break down, no power blackouts or something to compensate for them (a UPS unit or generator for example) and so on. In other words, this complicates things from a hardware point of view. Hosting your site on your own hardware is a very cool thing and offers you endless flexibility but you must make sure that the hardware functions and connects to the Internet properly 24/7. There were also other problems related to own servers until recently: you needed a computer to run all the time, which consumed  much power (which probably cost more than a hosting plan) and it needed a place in a building, a place where it bothered nobody with the noise it was making. So you had to be really motivated to keep a sever in you room at home if you had no other place for it. This last category of problems has been recently solved when the Raspberry Pi became available. The Raspberry Pi is small, it can be fitted anywhere in your house  it consumes so little power that you will never notice the difference and it is completely fan-less, with no moving components, so it makes absolutely no noise. Now that certainly opens up a whole new world of options. Now you can host your WordPress site on your own Raspberry Pi sever! Of course, you still have to guarantee that it runs all the time and that it has a good, permanent Internet connection. That might not be a big problem in most cases. there is, however, another aspect, which might complicate thing when using the Raspberry Pi with a WordPress website: the Pi has relatively limited hardware resources, it is not very fast and it has little memory, which can be a problem because, depending on the used template and on the managed content, WordPress tends to become resource-hungry. There are ways to attenuate this problem and the Raspberry Pi can successfully be used to host WordPress sites. In the following we’ll look at how this can be achieved.


Installing WordPress on the Raspberry Pi

  1. The very first step is to transform your Raspberry Pi into a LAMP server. This is required because WordPress is built upon PHP and MySQL and you will also need an HTTP sever, like Apache, for the site to work. Detailed instructions on how to achieve this can be found here.
  2. The second step is to download the free WordPress software from the official site: wordpress.org. The latest version can be acquired from here.
  3. The third step is to install WordPress on your Pi and do a basic configuration for it to get it working. the official WordPress website has a very good, detailed, step-by-step guide about how this can be done. Following the steps should give you a fully working WordPress website in about 10 minutes and it requires only very basic Linux operation skills, as everything is explained in detail.


Optimizing WordPress for the Raspberry Pi

If you have followed the installation steps above, you should have at this point a fully working WordPress website on your Raspberry Pi. However, as soon as you start adding some content to it (a few posts and pages), especially heavier content (images, plug-ins), you will notice that the performance of the website is becoming unacceptable. The loading time of the posts/pages will start to become unbearably long, which will not only annoy you, but also your readers and the search engines will start penalizing your site.

In order to avoid having a sluggish website, we need to make some optimizations. There are many ways to go about this but the keyword is mainly caching. This is because the Raspberry Pi’s processor isn’t particularly fast and the SD card‘s reading speed is also quite low (I think the theoretical limit is 30 MB/s). Caching the elements of your website will allow the Pi to serve your pages a lot faster from memory.

The easiest way to cache the elements of your WordPress website is to use a WordPress caching plug-in. there are a few really good ones out there. The one I have found to work best is WP Super Cache, which reduced the loading time of my pages to about 20% (5 times faster!) after the first access.

In order for WP Super Cache (or other caching plugins) to work, you will first need to switch to a custom permalink format. Read here how to do that.

After installing WP Super Cache, you should go to Plugins/Installed Plugins in your WordPress control panel and click on “Settings” below the caching plug-in. Here are a few settings that I have found to work well:

    • On the “Easy” tab enable the caching (Caching On)
    • On the “Advanced” tab
      • Check the “Cache hits to this website for quick access” box
      • Choose the “Use mod_rewrite to serve cache files” option
      • Check the “Compress pages so they’re served more quickly to visitors” box
    • Expiration options:
      • Cache timeout: 86400 seconds (24 hours)

Besides optimization on a software level, there are a few things that you can do with the hardware too, in order to obtain better performance:

    • Get the newer Raspberry Pi, model B, revision 2, with 512 MB of memory, not the types which have only 256 MB of memory.
    • Use raspi-config from command line to give the system as much memory as you can (by taking it away from the GPU, which will not need it anyway because your Pi sever is probably not going to run much in graphical mode). Leave the minimum amount of memory for the GPU (16 MB for example) and give the rest to your server-related applications.
    • Overclock the Pi’s processor. By default it runs at 700 MHz, but it can be overclocked without much risk even up to 1000 MHz. You can change the processor frquency using raspi-config.
    • Use a fast SD card, preferably one that can achieve 30 MB/s transfer rates.



WordPress on Raspberry Pi — 9 Comments

  1. Howdy! I could have sworn I’ve been to this blog before but after going through a few of the posts I realized it’s new to me.
    Anyhow, I’m definitely happy I stumbled upon it and I’ll be bookmarking it and
    checking back frequently!

    • Thank you! Please keep in mind that this blog runs on a Raspberry Pi in my home. Sometimes the internet connection breaks, other times I need to back up the SD card, so it sometimes (rarely) happens that you cannot access it. In that case please try again later. Also, I don’t have much time these days to write new posts, but be patient, even if after a long time, they will come 😉

  2. Pingback: Raspberry Pi + Wordpress => PiPress | Dev Leader

  3. Really helpful post. I’ve just done this myself but hadn’t overclocked or reallocated GPU memory. I’ve now done those too and the site seems a little faster. Nothing like as fast as yours though. Are you still running on the Raspberry Pi? I’m using Fast Cache rather than Super Cache so might have to look at switching if that’s the difference. It could just be that I have a slow uplink connection, I suppose.

    Just a pointer for those new to Raspberry Pi who might be following this post – if you can’t restart after overclocking, don’t panic! Just disconnect the power then hold down the shift key while you reconnect it and wait for it to start up. Once it’s running again you can then try the next level down until one works.

    • Yes, the site is till running off my first Raspberry Pi. It’s not overclocked, but the memory share is set to minimum for GPU and maximum for general usage mem. Also, I’m running BOINC Manager on the same Pi, which is using the CPU to 100%, and still the site loads pretty fast. I guess WP Super Cache makes the difference.

  4. Pingback: Powered by Wordpress, running on raspberries - I am Davin

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.