Development Seed Blog

Building Open Source Applications for OLPC with Drupal

One Web Server + Drupal Per Child

One Web Server + Drupal Per Child

We've been hearing a lot of talk about how the OLPC (One Laptop Per Child) needs more software developed for it if it's going to really live up to its potential impact. Since lately we've been developing some generalizable applications like a Disaster Relief Stick that runs a disaster relief toolset on a USB drive, an intranet package to help geographically dispersed teams communicate, and our first product Managing News (all built on Drupal), I thought it would be fun to see how easy it is to get Drupal running on the OLPC laptop and to see what the potential is for some other cool applications like these getting on there. 

Turns out that Drupal could be a flexible software application for the OLPC laptop. Three hours later (minus four hours spent hunting down a bug noted below) Drupal was up and running. Right now, I'm viewing the Drupal site being served off the OLPC next to my desk from my MacBook via its private IP address. Wow, it's fast! The hardest part about the installation was the small keyboard ; ).

Just think of all the applications that - once made lighter - students could get on their OLPC laptops. Our next move it to get our intranet package on the OLPC machine - its light weight wiki could help students collaborate together on their own machines. You can imagine how Drupal and OLPC can be used to help organize classrooms where students use OLPCs in a mesh network, with or without greater internet connectivity. We all know Drupal can do practically anything and can usually do it quite well. Now there is the opportunity for classroom intranets, student-editable wikis, and teacher portals to run on OLPCs. Each OLPC can be a web server, with the potential to serve Drupal to other students and teachers. That leaves the possibility for each child of OLPC to become a web content manager, a web server administrator, a content collaborator/creator, and ultimately, a Drupal hacker.

But getting back to what you really want to know - how we did it. (Note: We'll maintain a wiki of these instructions on the groups.drupal.org page.)

First, I thought about the order of operations, and what would make sense to try out first. It's important to keep in mind this is just a first iteration. You may want to replace the Apache with Lighttpd, the MySQL with another database, etc. But, the following process was very quick as an experiment. Since I'd be hopeless if Apache didn't work, that's where I started. I then installed PHP and got the two talking. Then I installed MySQL and connected MySQL and Apache with PHP. Here are the basic steps.

YUM. The OLPC comes with Yum, a package manager, which makes installing the binaries for the AMP stack pretty easy.

Install the web server applications. You need to be connected to the internet for this:yum install apache php mysql mysql-server php-mysqlIn this installation process, I ran into a couple out of memory errors while installing.  You can try a few things to avoid these.  I just installed each separately, like:yum install apacheAlso even with installing each separately, the PHP install in particular gave me memory errors. I shut down the other applications I had running on the OLPC, and then installed php again, and on the third try, it worked fine.

The web root on the OLPC is/var/www/html

I wanted to give the OLPC a nice localhost URL, so I went to /etc/hosts and added the line:127.0.0.1  lilds.devNow we can get to the web server root at http://lilds.dev (or http://localhost).

This will not work until you start Apache:/etc/init.d/httpd start

Then, you can make a test file in /var/www/html/ with a call to phpinfo(); to see your setup. You will want to make sure this is not owned by root so the web server can execute it.:<?php  echo phpinfo();?>

One hold up in the installation process was a missing sym link to the libmysqlclient.so.15 shared object file. You will need to make sure there is a symlink in /usr/lib that points libmysqlclient.so.15 to /usr/lib/mysql/libmysqlclient.so.15.0.0. If the sym link was not made with your installation, you can just do:ln -s /usr/lib/mysql/libmysqlclient.so.15.0.0  /usr/lib/libmysqlclient.so.15

You'll then want to start MySQL and make a database and a user. You can start mysql like:/sbin/service mysqld start

I noticed that after shutting the OLPC down and turning it back on, mysql was unable to run. For some reason the directory where it stores its pid was missing. I had to recreate this after starting up the LAMP stack a second time and still need to look into why this happened. One idea is that it's a user/permission issue. But if mysql cannot start there's a chance it's related to this missing directory.  Just do:mkdir /var/run/mysqld

I had a similar issue with Apache, where it's directory and log file were wiped out. You can recreate that if needed:mkdir /var/log/httpdtouch /var/log/httpd/error_log

After you get MySQL running, you can make the database for Drupal and a user. Then just download Drupal from Drupal.org and follow the instructions for installation. There's a chance I may have missed a step, so I will keep a wiki of these instructions over on the Drupal Group.

Happy hacking!

Comments
wonderful demo

I'm a journalism prof just starting to look into Drupal for our school, but also a G1G1 XO owner... I think there are great possibilities here...

The OLPC group in Uruguay is looking for a collaborative writing/journalism application. I'll point the guy here who sent me this...

http://wiki.laptop.org/go/Talk:Learning_activities/Journalism
#Collaborative_Editing_and_Publishing_Tools

http://tinyurl.com/3at8pc

regards,

Bob

Bravo!

Very cool. I need to try this with my kids. I have been using the XO as a tool to prepare them for the future and their own CMS is a great idea.

Thanks
johnmwillis.com

Thanks for the comment,

Thanks for the comment, John. What do your kids like most about their OLPC's? I think the possibilities of teaching web application development on the XO at an early age are pretty exciting, but I wonder how much kids would enjoy it...I would imagine it would be pretty cool since they can easily share their work and even make it useful w/in their schools and communities.

Ian

Another HOWTO

Hi All,

I wrote another HOWTO over at the OLPC wiki: http://wiki.laptop.org/go/Drupal

This one uses Lighttpd instead of Apache, which is a little more friendly memory wise. I did look at SQLite too, but it still requires an amount of tweaking if you run contrib modules.

I also have some short scripts to work around the /var impermanence issue, and make it convenient to start/stop when needed.

I'll post a short video on planet showing it in action (should have posted it earlier to avoid some duplicate work, but life overtook, as usual...).

Thanks!

- Owen

Comparing stacks

hey Owen, that's awesome! I am sorry I did not find your how-to and prior work before embarking, but it's good we've got two stacks to compare now. Are you coming to DrupalCon? We'll bring our OLPC along and hopefully we can check them out side by side. Good explanation for the loss of the mysqld and httpd directories within /var. It makes sense as to prevent log files from filling the tiny drive. I'll have to try routing these elsewhere if possible and cleaning just the contents, not the dir's themselves.

Ian

Using lighttpd?

For a laptop with small memory wouldn't it be better to use lighttpd instead of apache?

Hi Joaquín, thanks for your

Hi Joaquín, thanks for your comment. That's what I would suspect, yes. I also wonder whether another database server like SQLite may be faster as well. I went with Apache in the stack because I've been dealing w/ Apache a lot lately and am most familiar w/ it at the moment. However, we're really excited here at Development Seed to see how other stacks like w/ Lighttpd as the web server compare, performance-wise. We just need a few more spare laptops to do some more experimenting and do some real benchmarking. I did notice while browsing the site from the OLPC web browser, it was a little slow. However, accessing the site from my MacBook from within our network the OLPC was super-fast! Anyone else who has an OLPC and is working with Drupal, we can collaborate over here http://groups.drupal.org/drupal-olpc

thanks!
Ian

Post new comment
The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <img> <p> <li> <ul> <ol>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options