Category Archives: General

This site is a mess…

Let’s face it: this site is a mess.

It never came off the ground after a decided to use WordPress. Fooling around with stuff like multi language support has not done it any good. Problem was/is that I spend more time on other people’s sites than my own. Time to change a few things. Time to start doing what I like: post stuff about technical problems I encounter.

I made myself a todo list:

  • Check the relevance of  “old stuff” I wrote which still seems to turn up on google. Like a piece I wrote in something like 2004 about Slackware’s init system. To my surprise I found a reference to it in the AOLS FAQ file.
  • Write more on stuff like my old skool backup system. I made something like rdiff backup. I used stuff you normally already use, like cp and rsync. (To be honest… never heard of rdiff backup until after I wrote it)
  • Don’t worry about language… just do english like I did before.
  • Don’t worry about SEO… just write.
  • In general have more fun with it.

Lets see where this brings me…. here goes nothing 😀

WordPress on a Raspberry Pi B using Nginx

pi-wordpressI already mentioned I host my girlfriends WordPress site – and this site – on a desktop computer. That desktop computer is an old left over Dell Latitude. For some reason this computer makes quite a bit of noise. Which wouldn’t be a problem if my “server room” wasn’t actually my spare bedroom. I could try to resolve the noise issue – it is the fan making a mess of it – but I’ve never been a hardware guy.  That, and a thread on the NedLinux forum (in dutch, sorry about that :D) about what we are doing with our Raspberry Pi, made me decide to make a web-server out of the Raspberry Pi B I’ve got lying around.

So I started on a journey with the ultimate goal to have a hosting system for a WordPress site which is quit and has an acceptable response time. And keeping in mind the journey, which should be as valuable as the goal.

Having trouble actually finding my Pi I started the journey with a very basic setup on an Alix 2d13 board. Did some pfSense lab work on that board but finished that project some time ago. I installed a Debian system on it with Apache2, PHP5 and MySQL…. it turned out to be fun to do but slooooooow. Exit Alix board, also since I found my Pi in the meantime.

nginxTalking to a co-worker about the project the idea of replacing Apache2 as the actual web server emerged. A http servers like lighthttp an nginx would suffice for my needs, perhaps even better. Lacking any experience with lighthttp or nginx made the journey more interesting. After reading up on the performance of several lightweight http servers I decided to give Nginx a try.

raspbianI decided to install Raspbian on my Pi. Giving me an environment which I’m familiar to with the ease of “burning” an image to an SD card.   This is all pretty well documented on the Raspberry Pi download page. This image is actually being maintained by de Raspberry community, not the Raspbian community.

Raspbian gives you the apt package manger. This makes it easy to install your packages. For my Pi I installed the following packages using apt:

  • nginx
  • php5, php5-cli and php5-fpm
  • mysql-server and phpmyadmin

As a side note: Not really sure where it came from – perhaps it was already there on the Raspbian image – but as it turned out I had Apache 2 installed. I stopped the process and made sure with “# update-rc.d -f apache2 remove” that it wouldn’t start again. You can’t have 2 daemons claiming port 80 and 443.

php-fpm-logoGetting Nginx to serve up PHP generated content turned out to be the biggest issue. There is no php-mod for Nginx. That’s why php5-fpm is installed. Turns out Nginx is a proxy which sends the request to a “PHP CGI script engine”.  Php-fpm is used to spawn the necessary threads.  Nginx and PHP are seperate processes. They communicate either via a unix socket or a TCP connection.

The first thing I did – after getting Nginx to server up static content – was to make sure Nginx would serve up the result of phpinfo(). This sounds trivial – and should be just that – but Nginx is not Apache which I’m familiar with. The Nginx Wiki is full of warnings not the get misinformed by all kinds of blogs giving bogus information on how to do things. So I kinda stuck to the instructions given on their own site.

The page I ended up with on using was Martin’s Nginx, PHP, Primer. I explains quite clearly on how to serve up dynamic content. Only thing which confused me a bit was that Martin includes the file “fastcgi.conf” which Nginx expected to find in “/etc/nginx”. The debian installation I have did have a file named “fastcgi_params”. Nginx did not complain… so I figured that was the one he intended.

Next thing I needed to figure out for myself was the pgp-fpm thing. I wanted to make sure I understood the way the two processes (nginx and php) were talking to each other. Unix socket or TCP.  Turned out this configuration could be found in “/etc/ph[p5/fpm”.  A file “www.conf” in the subdirectory “pool.d” controls such things.

After I corrected the syntax error in  “index.php” (I used the function php_info() instead of phpinfo() (hey… I’m a Perl guy)) it worked as expected. No worries there. On to WordPress.

Writing this blog I’m wondering why I didn’t just paste in the WordPress code. But instead I googled  for “WordPress Nginx” and found some references on the Nginx Wiki. And they have a complete page devoted on that subject. No a big surprise since they state on their homepage that is hosted on nginx.

But anyway… after using that config WordPress just works. An empty WordPress with one article added loads in 3-4 seconds. No plugins enabled. Not to fast I know. The troubles started when I added content and enabled plugins. The aforementioned girlfriends site loads in 10 seconds plus, testing done from within the same subnet. Not really acceptable.  By using the php-apc module I managed to reduce the load time to 8 seconds plus. Impressive…. yes… but not enough.

failedIn conclusion: I did not reach my goal. The Pi B simple does not have the power to support a website with scripted backend. Sure I could have enable a caching plugin. In effect making the site content static for visitors, but not for the writers of the site.  But the journey was fun. Getting Nginx to work was kinda like going back to the basics of things. It made me decide to order a Rasberry Pi 2 model b. A Pi with a quad core 1ghz processor. But that is something for another blog 😀

Going multilingual

 Borderless Bilbo’s-Stekkie.

multilingualFor some years now I write articles to share the things I learn. Most often they are about technical stuff which – so I’ve learned – are of interest to people outside the Netherlands.  So I’m often in doubt to write in either dutch or English. The site should probably be multilingual. But how to go about something like that?

WordPress solves this problem for me with a plugin – WPML in my case – to write multilingual sites. So from now on articles posted on this site will be in dutch and English.  Maybe even the older articles.