A web and database server in your pocket with the Nokia N900

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!

A N900 web browser window showing the output of phpinfo

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.

An N900 browser window showing PHPMyAdmin

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.

An N900 web browser window showing a local installation of Drupal 6

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.

Comments

Hi Liam

thanks for putting up this great write up in your blog. Really useful and it's convincing me we should go with the N900 as our choice of mobile with keyboard on our project. Cheers!

I've seen this on wikipedia: http://wiki.maemo.org/Maemo_5/PR1.1#New_features - looks like some 3 connected N900's were having problems connecting, but a new firmware release is supposed to solve that.

That's right, the update meant you could use 3 SIMs with the N900 for the first time, which is what I am doing. Was happy when I put the 3 SIM in that I got sent settings by SMS straight away and the 3G Internet connectivity worked right away. They also sent a link to the page where you can check your usage.

Please can you help me to install Apache/MySQL server in Maemo 5 (Nokia N900)?
I don't have much experience in the Linux.

I love seeing this kind of thing being done with Easy Debian. You're right, eventually most of this stuff will be ported natively to Maemo, but why wait? ;)

Sorry for the second post, but just a tip to avoid installing unwanted packages. Use the --no-install-recommends option in apt-get when installing; this greatly reduces the amount of stuff that Debian will install.

apt-get install --no-install-recommends libapache2-mod-php

I can't promise that would get rid of exim4, but it likely would. It is a bit of a rabbit-hole trying to determine dependencies for big packages like this just by looking at the packages.debian.org website.

Thanks for this posting. Could you tell more detail how to install apache, php and mysql on N900 step by step. I am not familiar with Linux. Thanks.

hi
I tried install libapache2-mod-php in n900, it says " error " . says that few things not installed.

If possible can u help us with step by step installation with download urls. so that we can do installation by every step of your guide and if anything need to download for that step, we will use the url given by u..
so tell me wat is 1st step , what files we need to download for it and all details.

There are many waiting for it, your screen really great .

kindly help us....

hi
I tried install libapache2-mod-php in n900, it says " error " . says that few things not installed.

If possible can u help us with step by step installation with download urls. so that we can do installation by every step of your guide and if anything need to download for that step, we will use the url given by u..
so tell me wat is 1st step , what files we need to download for it and all details.

There are many waiting for it, your screen really great .

kindly help us....

Guys,

we dint get full details for installing web server in this post but, this post really helped me to configure my n900 to local web server.

i have not installed drupal for testing, i have installed my own developed website full version script with database and everything is very smooth.

this is not really easy step but if we understand properly, we can do it. i took some screens in it. i'll give u some tips..

goto app manager, search for debian. install it. then download lzma file from debian site, follow the links from this post.

we need to download lzma file manually from computer and transfer to n900. bcos we cant download it from mobile since it is realy 280mb

then run debian installer as per http://wiki.maemo.org/Easy_Debian instructions . thats it. open synaptic package manager. u will get list of app. u select apache 2, phpmyadmin, mysql server and which ever u like to install... once u made. check http://localhost u will understand.

also all website scripts need to place in /var/www/ this folder can view only by Debian Chroot.

in my next post, i'll prepare screen and post u. so that u guys will get useful.

Hi Rasu, yes you have to do this through an Easy Debian installation, the packages are not available natively yet for the N900. When you install Easy Debian it should offer to download a Debian image, you shouldn't have to copy it to the phone yourself.

hey dude your help supported a lot.

there is option to download manualy.lzma file to your pc and put it in n900 MyDocs folder and when u run image installer, it will detect.

Now i need small help from you, i did restart my n900 after installing additional audio/video codecs.

Now my localhost is not working. can u help me how to get back ?

i got code to restart

chroot

/ect/init.d/apache2 restart

or

apache2 restart

hey Liam

i made everything now, only thing left is mod rewrite. i made the same code in chroot " a2enmod rewrite " , it says mod rewrite enabled. but my urls are not working. not sure why it is, so i use normal url to make site run. do u have any other option to configure mod rewrite ?

i got command for restart apache2 and mysql. everything is works perfect and even in debian OS. if i face any prob, i'll post message.

i would like to paste step by step installation in my next post, to help others.

Liam, If u can able to check my mail id, keep in touch we will share.

all credits goes to you.

Are you running a Drupal installation? If so check that you have modified the value of "RewriteBase" in the .htaccess file at the base of your Drupal install. It should match the root of your site, e.g. if your site is at http://localhost/drupaldemo it should read "RewriteBase /drupaldemo".

Hope this helps!
Liam

hi, with the new maemo update pr1.3, the stuff above does not install smoothly? any idea how i can go about this? i'm not quite familair with linux system yet. i've already installed easy debian. but when i install libapache-mod-php and mysql servel, i get dependency errors. i think version conflicts. anybody who can help me with this is appreciated. thanx

Hi, unfortunately I don't have the N900 any more (it was a trial unit) so don't know about PR 1.3. Can anyone help MrAL? One thing to try might be to do "sudo apt-get update && sudo apt-get upgrade" *inside* easy debian. This will update the database of packages and upgrade the installed packages to the latest version. Sometime dependencies issues arise if this information is out of date.

thanx much sir liam... i'm updating the packages now...i'll just try to install everything again...and find a workaround for this stuff...if i get it right, i'll post the result here...thanx guys.

Command to run for installation after launching chroot

apt-get install libapache2-mod-php5

The original article misses that 5 at the end.

hey guys,

New Maemo version update available for our N900. click update in App Manager and check it.

Its around 100mb so, use wifi connection to update also, keep ur charger ON for battery.

New version support subtitle fix, landscape n portriat web browing by rotating mobile, calender update, internet video calling, email widget.

even after Maemo updated, i can run my web server. jquery works perfect.

Thanks to Liam for this web server article.

I just tried to do this using the most up-to-date Easy Debian and etc and had some difficulties. I eventually got it to work by making the following changes:

(1) In /etc/apt/sources.list there is a line with

http://www.backports.org/debian lenny-backports main contrib non-free

I had to change it to this:

http://backports.debian.org/debian-backports lenny-backports main contrib non-free

(2) As mentioned above, the package is named libapache2-mod-php5 instead of libapache2-mod-php (note the addition of the "5")

Then obviously the expected sudo apt-get install libapache2-mod-php5

This at least got me to the point where apt-get started installing something. I'll update later if any further instructions are needed...

Hey Liam,
I have followed your instructions regarding Drupal6, including "RewriteBase /drupal6" (double quotes must be omitted), but when I type the URL: http://localhost/drupal6 I end up with a blank screen.
Could you please help me out?
Thank you.

Problem solved! I went through the http://localhost/drupal6/initial.php dialogue and when I finished it was fixed.

Add new comment

Comments are always very welcome, but please note the following:
  • Sadly due to the high number of spam comments recently all comments are now manually moderated. You comment will therefore not appear on the site instantly.
  • Comments on this web site are monitored for spam using Mollom. By posting a comment, you accept that your message and other personal details about you will be analysed and stored for anti-spam and quality monitoring purposes, in accordance with Mollom's privacy policy.
  • Please use your own name not a company or website name to submit comments. Your comment will be removed if you don't do this.
  • All links in comments will be marked with a no follow attribute. That means posting a link to your site here won't help your search engine rankings.
  • By submitting a comment you agree that your comment can be reproduced under the same licensing terms as the rest of the content on the site.
  • Comments can be removed at any time without explanation, but won't be removed just because you disagreed with something I said.