Since my last blog post on the Nokia N900 I have been experimenting more with this Linux powered device and thought it was time to go a little further to see what it could do. Just over two years ago I wrote about using the Asus EEE PC as a “server in your handbag” running Apache 2, MySQL and PHP. I could not help wondering if such a feat was possible on the N900, after all it is a Linux machine, a small computer, but running the LAMP stack on a mobile phone? Maemo, the N900's operating system is a derivative of Debian, but the packages needed have not (yet) been ported, however, there was another route: Easy Debian.
You may recall in my last post about the N900 that I installed Easy Debian and had a look at some desktop software running on the device. The Debian repositories for ARM processor powered machines (like the N900) also include the software for the LAMP stack. In fact Debian is available for twelve computer architectures, which is probably more than many IT people can name! So I tried out installing the LAMP stack from inside the Debian Chroot environment (when you install Easy Debian you get an icon to take you to that).
First I installed Apache 2 and PHP by installing the libapache2-mod-php package in Debian (thanks to the dependencies system in apt this means both bits of software get installed). The installation went smoothly, the only thing I did not like was that packages for Exim got installed as part of the dependencies, not a massive problem, but my preference would have been not to a mail transport agent automatically. When I typed “http://localhost” into the N900's web browser I noticed that it came up with that reassuring message “It works!”, so that was a good first step. To get PHP working I had to restart the Apache 2 web server as I think PHP gets installed after Apache so it does not pick up the PHP components (this is why you might be invited to download a PHP file rather than it running in the browser). I wrote a little PHP script to call the phpinfo() function and put it under /var/www (in the Debian Chroot environment). It worked!
Next I installed MySQL server with the mysql-server package. This went smoothly, I got the usual debconf dialogues to help me set it up. When I logged into MySQL from the command line everything seemed good, but sometimes it is nicer to have PHPMyAdmin which will be familiar to many developers and quite a nice web based front end to MySQL. Fortunately, this is in a package too: phpmyadmin, the only thing you need to do in the configuration for this is to state that it should work with Apache2. I went back to the browser and typed in http://localhost/phpmyadmin. After a couple of seconds it loaded. As the N900 was connected to my network I could also log into it from other machines (though not from outside my network due to the firewall in the router), so if you use this you might want to change the configuration of Apache to only allow connections from certain hosts.
I also tried out installing Drupal 6 to see if it would work. Installation pretty much was the same as on other Debian or Ubuntu systems, I enabled the Apache rewrite module to get clean URLs (using the command: a2enmod rewrite) and installed Drupal using its installation wizard. I set up the database for it in PHPMyAdmin, and yes copied and pasted the randomly generated password to Drupal! It worked, although I have not done much with the installation, it was quite something to see Drupal and the LAMP stack working on a mobile phone. I assume that it would be possible too to port all of the modules to Maemo to do this one day which would remove the need for the Debian Chroot environment.
Having all of this installed on the device did not seem to make it slow down at all. I am sure you could not really connect many users to it, but it is very interesting that this all works on a device like this. It is not something I would recommend at all to novice users. people who regard their N900 as “mission critical” or even sensible people. So why do it? Like the people who try to install Linux on everything (maybe even a dead badger) I am curious about installing web servers on devices. There are still people who are surprised when I tell them that I run the LAMP stack on netbooks; people sometimes presume such things are not possible and that is why we sometimes have to do things just because we can. This has been a good reminder to me about how powerful mobile devices are becoming and how flexible Linux is. I have heard it said that mobile phones are only ten years behind desktop computers in terms of processing power, this opens up all sorts of possibilities even having a web server in your pocket.