PAMP: Personal Apache MySQL PHP
Those of us familiar with dynamic web programming have most likely heard the term LAMP (Linux, Apache, MySQL and PHP). LAMP refers to a stack of software used to run a website or server. In LAMP, Apache is the web server, MySQL is the database and PHP is the programming language. Good news is that, as the outcome of the open source research of Nokia PAMP, the AMP stack for Series60 mobile devices is now available. Now a Series60 device can be turned into a web server - LAMP users can publish their PHP sites on their mobile devices which can be accessed from anywhere in the world.
The PAMP Stack
In the Symbian Series60 environment the AMP stack is implemented over Open C. Open C is a set of industry-standard POSIX and middleware C libraries for S60 on Symbian OS. The stack can be something like as below:
Figure 1. The PAMP stack
In PAMP, PHP and MySQL are both version 5.
The pre-requisite for running PAMP is a Symbian Series60 3rd edition handset having 128MB of free RAM. As per the PAMP wiki they have tested with Nokia N95 8GB and Nokia E90. But any S60 3rd edition phone with sufficient memory should work. (This author used a Nokia N95 4GB)
The PAMP installation package can be downloaded here. There are two versions (both are zipped): pamp_with_htdocs_on_c.zip and pamp_with_htdocs_on_e.zip. E: drive is the memory card. The package contains the following files
These files should be extracted and installed on your mobile sequentially. One approach is to connect your mobile to your PC via USB cable and then use Nokia PC Suite to install the applications (sis) one after another. Then if you visit the installed applications folder on your handset you should see three new applications (illustrated below):
Figure 2. Installed applications
These applications are: Python (Python For Series60), Pamp (Personal Apache MySQL and PHP) and the Connector (which is used to give the mobile HTTP access).
So now you are ready to work.
Building a Network of Connectivity
Figure 3. PAMP network architecture
A detailed description on connectivity can be found here. In the rest of the article we demonstrate how to create a network similar to the illustration above, where the webserver is running on the Nokia N95 and the webpages hosted on the N95 will be accessed from the LAN or from the Internet.
Creating the LAN
We create the WLAN Ad-Hoc network so that the Wi-Fi enabled devices can access the N95 Webserver. The steps are given below.
First we will set up a new Access Point. On the handset visit Tools -> Settings -> Connections -> Access Points[Option] -> New Access Point. Now enter the parameters on the New Access Point configuration screen.
Connection name: Self [Or anything what you think will be nice.]
Data Bearer: Wireless LAN
WLAN Network name: Anything [I put MuntasirLAN]
Network status: Public
WLAN Network Mode: Ad-hoc
WLAN Security Mode: Open network
The new access point is created. We will now start PAMP. So now go to Menu -> Application -> PAMP -> Option -> Start -> Pamp
Figure 4. Pamp service management
Wait until Apache and MySQL is not showing the status as “Running”.
Now again go to Option and “Start WLAN”. It will search for the available WLANs where you will see the WLAN named as “Self” (created in Step 1). Select this one and wait till WLAN AP shows “Self” and you see an IP against WLAN IP (We got the IP 169.254.70.62).
Now we have set up the Ad-hoc wireless LAN. Any device having WLAN facility can search for available WLAN access points. As the WLAN is started in the phone so the Laptop will find a WLAN access point (in my case it was MuntasirLAN). Connect to this network.
Now from the connected devices (eg. Laptop) anybody can visit the websites running on the N95. The landing location will be http://WLAN IP address. In our case it was http:// 169.254.70.62. And if you visit you should see a page saying “It Works”.
Figure 5. "It works" - Default success page
New websites should be created in the location e:\data\apache\htdocs\Newweb where Newweb is the new directory which is holding the new site pages.
It is also possible to browse the websites residing on the phone without creating an Ad-Hoc network. Step 1 to Step 3 are the same. But in Step 4 instead of selecting the WLAN “Self” just select any existing WLAN which is available. Then using http://WLANIP you will be able to browse the websites.
Browsing the phone website from the internet
So far the phone websites could be accessed by the WLAN users. There are two approaches to making the PAMP server accessible over the Internet:
- Using Raccoon Gateway
- Using MWS Gateway
Here we use Raccoon. Raccoon is the original mobile web server that provides a mobile phone with http access from the Internet, using a transparent intermediate gateway. Raccoon requires an ID and a password created in the Raccoon Gateway. To obtain the ID you should mail email@example.com with the text "Raccoon Account" in the subject field of the mail. It is also necessary to provide the reasons for getting a Raccoon ID so that they can judge the necessity. When they provide you the account details they also provide you the with the URL of your personal website. In our case is was http://muntasir.mamun.at.openlaboratory.net:8080/ and http://www.at.openlaboratory.net:8080/~muntasir.mamun/ where the port was 8080. (Since 8080 is the default port we can omit it from the URL.
When a request is made for my mobile website (at the above address) the flow is as illustrated above in figure 3:
- URLs like http://muntasir.mamun.at.openlaboratory.net resolves to the IP address of the gateway computer (1)
- HTTP request delivered to the gateway (2)
- From the HTTP request headers, the gateway can deduce who the request is intended for
- The gateway then delivers the request of the connection opened by the terminal (3)
So the client making the request will see the page saying “It Works” - the handset has serviced the HTTP request.
Of course the first and most effective benefit is that: a webserver is running in the phone which has PHP and MySQL. But when you install PAMP the module mod_python is also installed. This is an Apache module which enables the Python interpreter in the server so that python functions can be used. Already Nokia has published Python For Series60 (pys60) which brings the power and productivity of the Python programming language to the S60 platform. And using the module the camera, contacts, inbox etc can be accessed. So mod_python can be used to run the pys60 modules to access the system and feature access of the phone giving added benefit to the developed websites.
So now you're up and running with a webserver in your pocket. Have fun!