LAMPi – The Raspberry Pi LAMP Server Project now also has it’s own website! www.LAMPi.co.uk
Due to the horrible weather last weekend I found more time to play with my Raspberry Pi
I’ve got an Arduino/XBee based Wireless Sensor Network with associated storage/reporting back-end and ever since I put it together for a MSc coursework I’ve been planning to swap out the Mini-ITX LAMP server for a RasPi. In the long run I’m hoping to also add one of the XBee Series 2 modules to the RasPi so it can also take on the role of my current XBee-to-Ethernet concentrator (hence the Slice-of-pi boards in step 10). The following is a quick walkthrough of the necessary steps for setting up your own LAMPi and at the end a little section on how to read/write SD-card images, details on my first attempts to do a bit of load testing on the LAMPi with JMeter and further thoughts/links/accessory ramblings.
If you don’t want to set all this up yourself feel free to download my image. It includes everything from Step 1-7 and was created as per Step 8.1. In case you run the JMeter plan from Step 9 against one of these I’d be grateful if you could let me have results and details on your SD-card.
Step 1 – Preparation:
Since there is still a certain amount of “will my XYZ” work with a RasPi I’m going to start by listing what my RasPi is currently connected to. If in doubt buy kit which is mentioned on the official verified peripherals list. I’ve hooked up my prospective LAMP-Pi to:
- Samsung SyncMaster 226BW with a Belkin HDMI lead and HDMI-to-DVI adapter
- Cherry wired optical USB mouse, Cherry GENTTIX Model No: JM-03
- Cherry wired USB UK layout keyboard, Model No: JK-02
- Apple AC-to-USB adapter and a no-name micro USB lead
- CAT6 cable to a Netgear 8port gigabit desktop switch
- Integral 2GB mini SD-card with matching adapter
- Original Debian Squeeze image
If you are running the Squeeze image for the first time:
- Your user name is: pi
- Your password is: raspberry (raspberry is also the password for everything else I’ve installed below)
- Once you are logged in start LXDE (your desktop) with: startx
- To get screenshots install scrot and run scrot ‘%Y-%m-%d–%s_$wx$h_scrot.png’ -e ‘mv $f ~/Desktop’
- If you’re running headless you can reboot via ssh with “sudo reboot” or shutdown with “sudo shutdown -h now”
- If you don’t like the Midori get Chromium with “sudo apt-get install chromium-browser” and don’t forget to run “sudo chown pi:pi ~/.config” afterwards
- Most of the below will need root privileges. Start you terminal session with sudo su or add “sudo” in front of the commands.
ssh-keygen -t rsa mv /boot/boot_enable_ssh.rc /boot/boot.rc
I’m doing this from OSX so I use ssh username@yourip in a Terminal window. I think on windows you would like to use PuTTY but that’s not my world…
Step 3 – Let’s install Apache 2:
usermod -a -G www-data www-data
apt-get install apache2
To test point a remote web browser at http://your-LAMP-Pi-ip. As usual your website’s files will live in /var/www.
Step 4 – Let’s install PHP5:
apt-get install php5
To test put a file called phpinfo.php into /var/www:
This is what you want inside your file:
You might also want to install some of these, they all worked on my LAMP-Pi:
apt-get install libapache2-mod-php5 libapache2-mod-perl2 php5 php5-cli php5-common php5-curl php5-dev php5-gd php5-imap php5-ldap php5-mysql php5-odbc
service apache2 restart
To test point a remote web browser at at http://your-LAMP-Pi-ip/phpinfo.php
Step 5 – Let’s install MySQL:
apt-get install mysql-server mysql-client php5-mysql
To test run mysql -uroot -ppassword and replace “password” with whatever you picked when you installed MySQL (but leave the “p” in front of it!) which should get you a MySQL prompt (exit gets you out of that one).
Step 6 – Let’s install phpMyAdmin:
apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin
And add the extension to your Apache php.ini with:
add this and save:
To test point a remote web browser at http://your-LAMP-Pi-ip/phpmyadmin
Step 7 - Let’s install TightVNCServer (Optional):
And for all those situations where your LAMP-Pi is running headless but you still want/need a full LXDE desktop I’ve installed TightVNCServer.
apt-get install xorg lxde-core tightvncserver
To start it run: tightvncserver :1
And to kill the above session run: tightvncserver -kill :1
I use Chicken Of the VNC and all I have to do is enter the LAMP-Pi IP into the host box, “1″ into the Display box, put in my password and click connect.
Step 8 – Let’s install creating and writing SD-card images under OSX:
This one isn’t for the faint hearted as it uses dd. If you don’t know what dd is or think it means “disk destroyer” better get yourself a Windows based machine and use Win32DiskImager (http://www.softpedia.com/get/CD-DVD-Tools/Data-CD-DVD-Burning/Win32-Disk-Imager.shtml). If you’re on Ubuntu I’d recommend a nice graphical tool called ImageWriter (I’ve got Ubuntu on a Sony laptop next to me just for the task of writing images, it’s my fastest SD-card reader/writer . Step 8 – creating and writing SD-card images under OSX: This one isn’t for the faint hearted as it uses dd. If you don’t know what dd is or think it means “disk destroyer” better get yourself a Windows based machine and use Win32DiskImager (http://www.softpedia.com/get/CD-DVD-Tools/Data-CD-DVD-Burning/Win32-Disk-Imager.shtml). If you’re on Ubuntu I’d recommend a nice graphical tool called ImageWriter (I’ve got Ubuntu on a Sony laptop next to me just for the task of writing images, it’s my fastest SD-card reader/writer . I’m doing this on OSX 10.7 but it should be very similar on all OSX versions.
8.1 To create an image from a SC-Card:
- Insert SD-Card (my iMac has a slot at the side underneath it’s optical drive)
- Wait until your card get’s mounted on the desktop and make a note of it’s name
- Open Terminal and run mount. You’ll get a list of all your mounted devices and one of the lines should relate to your SD-Card. Mine was called “NO NAME” and I get this back from mount: /dev/disk3s1 on /Volumes/NO NAME (msdos, local, nodev, nosuid, noowners)
- Take the /dev/XYZ line and strip it back to just the device without the partition. In this case that’s /dev/disk3
- The following dd command then creates a image called lampi.img in your home directory: dd if=/dev/disk3 of=lampi.img
- The resulting image will be the size of your SD-card but there’ll be a lot of empty space in your image so it should compress well: gzip lampi.img
8.2 To write back an image to a SC-Card:
- Insert your target SD-card and wait until it get’s mounted to the desktop
- Unmount the SD-card with: diskutil unmount disk3s1
- To write the image to the SD-card with dd run: sudo dd if=lampi.img of=/dev/disk3
Step 9 – LAMP-Pi load testing with JMeter:
I’ve only done a very basic test against /phpinfo.php but, keeping in mind the size of the board and it’s power consumption, the results are impressive. It should serve very well for small/mid sized LAMP projects and with basic html content Apache2 should stand up even against higher visitor numbers. The same test runs with very much the same results in regards to speed from both an ancient 2GB Mini-SD-card and a fast 8GB SanDisk Ultra (15 MB/s, 4) but I will try again once I get my new faster SD-cards. Performance of the MySQL database will obviously be limited due to it running off the same SD-card as the whole underlying system but it will still work well as a storage backend. I’m going to write a JMeter test plan for the MySQL side later today and swap the board in as the storage/reporting back-end for my Arduino/XBee WSN to get an idea how it perfoms under real life conditions.
This is my test JMeter Test plan. All you need to do to use it is to change the IP under “HTTP Request Defaults”.
Step 10 – Further thoughts, links and accessory rambling:
This project looks very interesting: Raspberry Pi Thin Client project And once they release a final version I’ll try to base my further images on Raspbian rather than the original Squeeze image simply because it’s based on Wheezy rather than Squeeze and has hard float instead of the soft float cheat in the original Squeeze image.
The RasPi seems picky with USB hubs, I’ve got a few cheap ones and it did not like them too much (WG111v2 fails to work as described in the RasPi forum) so I’ve got two Belkin powered port ones on order which are supposedly fixing this issue. Although not on the official “tested hardware”-list my mouse and keyboard are working ok so far but I’ve got a Apple wired keyboards lying about which is on the list, just in case.
Buffered I2C expander boards seem to be on the way, so are other proto-shield type boards and I’m trying to get some “Slice of pi” boards. They seem really nice little things, break out all the pins into a little proto area and there’s even a XBee socket. And all this for under £4 including VAT!
The friendly postman left me a “you weren’t home” card yesterday so I got curious since I didn’t expect any deliveries. Farnell had given me a delivery slot for next week (28/05/2012 onwards) but a quick look into my profile confirmed that they had already sent it Followed by the usual 24hr wait and a somewhat restless night I finally managed to collect my first Raspberry Pi from my local main post office (at the other side of town, obviously) and documented the following “in car un-boxing” with a very happy tweet+picture Since I’ve been blessed with mandatory attendance at a XML training course although I have just passed a far more complex postgrad module on the matter of structured and unstructured data I had luckily already had time to prepare a repository of RasPi boot images and associated “stuff”. The following is a quick description of my first attempts to get some use out of the little board and at the end a couple of thoughts on further projects.
1. To stream or not to stream:
Personally I don’t think that’s a real question hence the fact that during the refurb of our semi I decided to pull a bunch of AV cables as thick as my arm through the crawl space underneath the floor boards from the media center (<- she would call it the front room…) to the cupboard underneath the stairs. Said cupboard now also houses the main fan-out points for the down stairs ethernet and DVB-T wall sockets. I had a basic Intel quad core based machine in there for quite some time to basically stream video content off the central raid server and experiment with ripped HD content (<- motivated by the fact that I do own HD-DVDs and a USB HD-DVD/BluRay writer but no stand alone home cinema HD-DVD player). I think there aren’t many “stream my stuff” apps that I haven’t tried over the years and where I’m too lazy to mess with Ubuntu+VLC XBMC has proven to be a nice couche potato type front end. Since the old streaming PC was finally retired a few months ago in preparation of this setup I set out to get it to work on the RasPi. Mainly to avoid having to hook up the quad core portable to watch the last and final episode of Desperate Housewives…
2. XBMC vs Raspbmc:
Initially I thought about simply messing with the original Raspberry Pi Debian image (http://www.raspberrypi.org/downloads) to see how hard it would be to get XBMC into that but thanks to my postgrad modules I now routinely write spec and google for about half an hour before I embark on any new project. As usual this saved me about an hours worth of compiling for ARM and god knows what simply due to this website and the links on it with the two current main projects for XBMC based RasPi images: http://www.raspberrypi.org/downloads . The contenders were quickly identified as OpenELEC (http://openelec.tv/news/item/241-openelec-meets-raspberry-pi-part-1) and Raspbmc (http://www.raspbmc.com/).
I’ve tried both and as much as I like the idea behind OpenELEC it’s simply not quite there yet, mainly due to the fact that it feels a lot slower which is obviously the main problem on such a power poor board. Although the current Raspbmc image (http://download.raspbmc.com/downloads/bin/ramdistribution/installer-testing.img.gz) is classified as Beta it’s already very usable, boots and reacts fast and dealt well with the plugins I threw at it. Personally I’d put this down to the fact that the developer behind Raspbmc is the same guy that brought XBMC and 1080p decoding to the 1st gen Apple so he knows how to deal with underpowered platforms.
3. Raspbmc – ready, steady, boot:
Personally I got tempted to play around with the non-HDMI screen sockets but they don’t seem to be implemented yet due to missing drivers so the little thing went up against a 50″ plasma. I haven’t bothered yet to try and connect the 3.5 mm jack headphone socket to the Yamaha 6.1 Amp and I’m not sure how well Raspbmc deals with above HDMI-stereo or real 5.1 output via the 3.5mm jack at the moment but since the audio chips seems very boring standard stuff I’d assume it should simply work or require minimal work at best which I’m sure will be finished until the final image goes out.
AV wise I’ve set this up as HDMI only to the plasma with video as 1080p/60hz and stereo audio through the same HDMI cable to the TV.
I’ve seen various posts of people who tried XBMC on their RasPi with very poor results due to very slow SD-cards so I got something reasonable fast in form of a 8GB SanDisk Ultra (SDHC, 4, 15MB/s) which seems sufficient to give the little board enough I/O umpf. Building bigger lists of files can take a second or two and the same goes for listing available options in some of the plugins which scrape data off the interweb but keeping in mind the underlying system and the fact that Raspbmc is still Beta this is not only usable but actually quite impressive. The current RasPi only has a 10/100 NIC which makes sense as the chip in front of the NIC simply wouldn’t handle more (especially on the upstream side) so I’m hoping that the next version comes with a decent gigabit NIC which should be beneficial once the board is meant to crunch HD content or scrape tons of data off some website/service.
4. Raspbmc – plugins (UK):
Installing the plugins is simply down to copying the extracted files into a folder on the RasPi boot SD-card or installing the usual repositories. I’ve only tried TV ones so far which work very well. iPlayer for TV and radio works straight away after copying the plugin over, even BBCHD works stutter free! The 4oD still has this annoying bug and I’vd forgotten how to fix it but the 5oD one works without the need to turn on the brain and rewrite the messy perl script that comes with these two. TVcatchup also installs but even in low resolution the video stutters which I think is down to the codec it uses. From what I gather the RasPi doesn’t deal to well with MPEG2 but I haven’t really looked into the spec details of the GPU yet. I’d assume all this is fixable as soon as more people have the boards and feed back bugs.
5. Raspbmc – smb streaming:
No real surprises here, streaming from an Ubuntu based Samba share is simple to setup and works without flaws. I’ve tried xvid and high resolution h2.64 files and all play without stuttering which I still find amazing for a board this size I’ll do more tests to find out where the limits of the GPU are and which codecs it digests best but I’d assume that it should deal with all the files people usually watch and it should at least match if not even exceed capabilities of functionality built into most recent TVs/BluRay players. It surely outperforms my one year old plasma and BluRay player in regards to capabilities as a media player.
6. What next:
As usual, lots of ideas in my head Apart from the fact that I want to establish what the board is actually capable of with Raspbmc in regards to max video/audio rates I’d also like to test more of the XBMC plugins and hopefully I’ll get lovefilm to work on this so I won’t be sent to the mail box again In regards to non media streaming projects I’m planning to try and talk to all sorts of ICs and Arduino shields once I’ve figured out what the pins do and soldered a few dirty adapter boards. I remember this Gert-board thing and Lady Ada had a RasPi proto board in one of her blog posts but I’m not sure if either are actually on sale yet. I think the first think I’m going to try to talk to will be I2C sensors and an XBee Series 2 modules simply because I’ve got some kicking about but if I get enough spare time I want to replace the back-end of my current wireless sensor network with a RasPi. It simply needs to suck up data frames from the XBee and then store them in an internal MySQL database. Since it’s got an ethernet port it could obviously serve flot graphs on the data through Apache like my current Mini-ITX back-end but this should be a lot more portable and energy efficient. Last but not least, if said graphs and more stats/details on the sensor nodes could appear on a touch screen mounted to the back of the RasPi I would have a full MySQL storage an graphical reporting backend running off 5V and possibly even off a mid sized solar panel hence off grid Oh, and I still need a decent case…