Template from my Android server run on an Asus Transformer Prime, will replace with a long-term template soon. :)

Android

Android is a Linux-based operating system for mobile devices such as smartphones and tablet computers. It is developed by the Open Handset Alliance, led by Google, and other companies.

Android has a large community of developers writing applications ("apps") that extend the functionality of the devices. Developers write primarily in a customized version of Java. Apps can be downloaded from third-party sites or through online stores such as Google Play (formerly Android Market), the app store run by Google. In October 2011, there were more than 500,000 apps available for Android, and the estimated number of applications downloaded from the Android Market as of December 2011 exceeded 10 billion.

Lighttpd

lighttpd is an open-source web server more optimized for speed-critical environments than common products while remaining standards-compliant, secure and flexible. It was originally written by Jan Kneschke as a proof-of-concept of the c10k problem - how to handle 10,000 connections in parallel on one server, but has gained worldwide popularity.

The low memory footprint (compared to other web servers), small CPU load and speed optimizations make lighttpd suitable for servers that are suffering load problems, or for serving static media separately from dynamic content. lighttpd is free software/open source, and is distributed under the BSD license. It runs natively on Unix-like operating systems as well as Microsoft Windows.

PHP

PHP is a general-purpose server-side scripting language originally designed for Web development to produce dynamic Web pages. It is one of the first developed server-side scripting languages to be embedded into an HTML source document, rather than calling an external file to process data. Ultimately, the code is interpreted by a Web server with a PHP processor module which generates the resulting Web page. It also has evolved to include a command-line interface capability and can be used in standalone graphical applications.

PHP can be deployed on most Web servers and also as a standalone shell on almost every operating system and platform free of charge. A competitor to Microsoft's Active Server Pages (ASP) server-side script engine and similar languages, PHP is installed on more than 20 million Web sites and 1 million Web servers.

PHP was originally created by Rasmus Lerdorf in 1995. The main implementation of PHP is now produced by The PHP Group and serves as the formal reference to the PHP language. PHP is free software released under the PHP License, which is incompatible with the GNU General Public License (GPL) due to restrictions on the usage of the term PHP.

What does this mean?

Combining the power of the three software packages aboves makes is possible to run your own small PHP enabled webserver on your android powered device anywhere anytime. This site is a demonstration of that, it runs on an ASUS Transformer Prime powered by Android ICS. It is rooted to run lighttpd and PHP with the correct tools. It utilizes the tools offered by busybox.

Requirements

  • Android powered device
  • Root acces (rooted device, howto differs per make/model)
  • Basic linux knowledge (you shouldn't be afraid of a shell)

Things to keep in mind

When trying to do ANYTHING remote (ie download remote page/file, ping, lookup, etc) with a hostname, be prepaired to enter in your shell environment. The way android handles DNS differs from other Linux environments. You may get unsuccesfull results when trying simple commands like ping, nslookup. This may be caused by Busybox being compiled against wrong libraries. My solution was getprop/setprop (only hint, for the rest there is google)

Your DNS settings may be overwritten when the devices reboots and/or reconnects to a (different) network. Making a script is a must.

Do not use your ISPs DNS as they may block request not originating from their network, remember your using a portable device.

Have patients