Contact

Thank you for your message, I will get back to you soon. ×
There was a problem sending your message, please try again later. ×
Please enter your name
Cancel

The Raspberry Pi

Comments
Imag0154

Almost everyone has heard of the Raspberry Pi now, well if you pay any attention to the news you will have.

The Raspberry Pi is a tiny computer, the approximate size of a credit card, designed to teach basic computer science to kids in schools. It consists of a 700MHz ARM11 CPU, VideoCore IV GPU, 256Mb RAM, HDMI, Ethernet, USB, and most important of all, costs as little as £30 (inc. shipping costs).

The price is really what sells it, it’s a surprisingly versatile machine, and at £30 it’s pretty much the cheapest computer you’ll find. I had to have one of course.

I waited a very long time for my Raspberry Pi. Having first hearing about it in 2011, it took up to March 2012 for it to be announced for sale. I got up at around 6:00AM, and attempted to purchase but it failed horribly. The demand was too large, and the websites were down throughout most of the day. Eventually in the evening I managed to register my interest for one, and proceeded to wait. It took until May for me to finally be able to order my Raspberry Pi, and then I had to wait another 5 weeks for it to arrive. Now June, it finally arrived on my doorstep.

Unboxing

For essentially a bare board, the device was well packaged and came with some nice informative materials:

Booting up

Having not received my new SD card (an 8GB Transcend Class 10), I put off properly testing the device, instead giving the Debian image a spin on a spare 2GB unbranded MicroSD. I was very surprised by its speed. It’s by no means fast, I feel it’s even slower than my old Pentium III, but it did fairly well, although I did come in with low expectations of its performance. Considering the X Window System wasn’t using GPU acceleration too and using a framebuffer instead, it wasn't that horrible.

When I finally received my new SD card (the next day), I wrote Arch Linux ARM (my preferred Linux distribution) to it. You can get all of these images from the Raspberry Pi website. It booted up surprisingly fast and I then configured the typical configuration files (rc.conf, locale.gen, hosts, resolv.conf – see the beginner’s guide here), set up a new user, changed the root password, installed and configured sudo, and updated the entire system. This took a fairly long time, and when it was finished I installed the X Window System, LXDE, and some relatively light apps.

I recommend you read the Arch Linux news before updating, I know that I at least had to be careful updating the filesystem package.

Using Arch Linux was a fairly similar experience to the Debian image, performance wasn't great, nor did I expect it to be. The only problems I encountered were an occasionally freezing mouse (I don’t know if this is a problem with the fact it is a wireless and thus more power hungry mouse, or the framebuffer being slow to keep up, or something else entirely) and also X crashing the entire system when being exited. Fortunately I won’t be using this as a desktop much, at least not directly.

The Raspberry Pi with everything connected

Improving performance

Arch Linux was just noticeably slower than Debian. As it turns out, Arch Linux has a different memory split to Debian, the 256Mb RAM was split evenly between the GPU and the CPU. Because I did not intend to use the GPU much at all, besides occasional desktop use, I changed the split to 32Mb memory for the GPU, and 224Mb memory for the CPU with this command:

$ sudo cp /boot/arm224_start.elf /boot/start.elf

And then rebooted.

Additionally the resolution wasn’t correct for my monitor, which meant adjusting the hdmi_mode value in /boot/config.txt to 16, which is 1080p at 60Hz. Other values for other resolutions are listed here. Note my config.txt also contains disable_overscan=1.

With that sorted, I then turned to using my Raspberry Pi remotely.

SSH and VNC

SSH was already pre-installed and configured on the Raspberry Pi. Still, I followed instructions at the Arch Linux Wiki, and made some adjustments to the configuration, including enabling only Protocol 2, only allowing my user to log in, and disabling root login. I also changed the port to not use the default port 22.

With that set, I logged in from my Windows desktop using PuTTY, and continued from there.

To access my desktop, I needed to install a VNC server. I opted for TightVNC. Again, I configured this using the Arch Linux Wiki. I also downloaded the TightVNC Windows client from their website, which allowed me to access my desktop from my Windows machine.

Connected to the Raspberry Pi through SSH

Accessing the desktop using TightVNC

Setting up a web server

My main intention with my Raspberry Pi is to set it up as a web server. I normally use Lighttpd (because it is relatively simple to configure for my basic needs), in combination with PHP and MySQL. The following information is derived from the Arch Linux Wiki, the material there is a little more confusing to follow with it taking into account other web server software.

Lighttpd

I first installed Lighttpd:

$ sudo pacman -S lighttpd

I then installed FastCGI (for PHP amongst others)

$ sudo pacman -S fcgi

And created a new file /etc/lighttpd/conf.d/fastcgi.conf containing the following:

server.modules += ( "mod_fastcgi" )

I then modified Lighttpd’s configuration at m/etc/lighttpd/lighttpd.conf and added:

include "conf.d/fastcgi.conf"

PHP

Next, I installed PHP:

$ sudo pacman -S php php-cgi

And edited /etc/lighttpd/conf.d/fastcgi.conf to now look like this:

server.modules += ( "mod_fastcgi" )
index-file.names += ( "index.php" )
fastcgi.server = (
  ".php" => (
    "localhost" => (
      "bin-path" => "/usr/bin/php-cgi", 
      "socket" => "/var/run/lighttpd/php-fastcgi.sock",
      "max-procs" => 4, 
      "bin-environment" => (
        "PHP_FCGI_CHILDREN" => "1",
      ),
      "broken-scriptfilename" => "enable"
    )
  )
)

MySQL

I then installed MySQL:

$ sudo pacman -S mysql

Started the MySQL daemon:

$ sudo rc.d start mysqld

And then proceeded to run the secure installation:

$ sudo mysql_secure_installation

Follow the steps carefully, then when finished, restart the MySQL daemon:

$ sudo rc.d restart mysqld

Next, edit /etc/php/php.ini, and uncomment the following (remove the ; )

;extension=mysqli.so
;extension=mysql.so

Running the servers at boot

To ensure the Lighttpd and MySQL servers are started when booting the system, I edited the DAEMONS line in /etc/rc.conf to include mysqld and lighttpd:

DAEMONS=(syslog-ng network openntpd @netfs @crond @sshd @mysqld @lighttpd)

phpMyAdmin

Managing the MySQL server on the command line isn’t particularly easy, instead I use phpMyAdmin.

This can be installed on an Arch Linux system like so:

$ sudo pacman -S phpmyadmin php-mcrypt

Generate a blowfish secret passphrase here, and edit the /etc/webapps/phpmyadmin/config.inc.php to look something like this:

$cfg['blowfish_secret'] = 'qtdRoGmbc9{8IZr323xYcSN]0s)r$9b_JUnb{~Xz'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

Next create a file called phpmyadmin.conf at /etc/lighttpd/conf.d/ with the following:

server.modules += ( "mod_alias" )
alias.url = ( "/phpmyadmin" => "/usr/share/webapps/phpMyAdmin/" )

and add include "conf.d/phpmyadmin.conf" to /etc/lighttpd/lighttpd.conf.

Next, open /etc/php/php.ini and uncomment:

extension=mcrypt.so

Find open_basedir in the same file and add /usr/share/webapps and /etc/webapps:

open_basedir = /srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/:/etc/webapps/

And that should be everything. Although probably not a particularly robust setup, it is sufficient for development. If you're following this I recommend you still read the articles at the Arch Linux Wiki, as the phpMyAdmin configuration can be much improved. The Raspberry Pi functions well as a web server, and I was impressed by its performance, although I can imagine you could quite easily cripple it under load.

Conclusion

I like the Raspberry Pi. I think it’s excellent in its aim to teach computer science to children. For my use, it’s a nice little PC to just play around with. It is very versatile. Although desktop performance isn’t great, it works well as a web server. Having little electronics knowledge I’ve yet to do anything particularly low level with it such as using the GPIO pins, but the possibility is there. What I haven't mentioned much in this post is that its VideoCore IV GPU is also very capable. It can play 1080p H.264 video at 40MBits/s, and has fast 3D capabilities which support OpenGL ES 2.0. Support for it in software is currently minimal, but installing a distribution such as XBMC provides a decent media centre experience. I would definitely recommend purchasing a Raspberry Pi, there’s just simply so much you can do with it. Be prepared to wait for it though!