Using An Android As A Webserver

In the latest episode of XDA TV [Adam Outler] turned his Android phone into a webserver. At first this might sound comical, but the ever-increasing power of our handhelds makes it a pretty legitimate option. It’s hard to come up with concrete uses off the top of our head, but we’re sure there’s value in being able to pull the phone out of your pocket and serve some content.

The app BotBrew Basil makes the installation process nearly automatic. It gives you point-and-click access to install the lighttpd webserver package and set the daemon to run automatically at boot time. That’s it! Of course you need to supply your own HTML to be served. [Adam] used an HTML5 website template for this.

Next you also need a way to resolve the address of the phone. In this case it’s assigned a static IP from the router, and a dynamic DNS service provides a link that maps to the router’s location. But since these phones are running Linux (at least on the lowest level) it should be pretty easy to add a cron job which will send IP address updates to the service if you want to take the ‘webserver’ out in the world with you. You can watch the entire video after the break.

Ironically this is a big hardware upgrade for [Adam’s] webserver. The previous version was running from an Evalbot.

25 thoughts on “Using An Android As A Webserver

  1. Cool! Mobile and embedded devices becoming Web servers (in addition to Web clients) is the future and in my opinion quite important to enable an open Internet of Things. REST APIs for physical objects FTW!

  2. I could see something like this being used if one wants full control over content (to the physical level) yet allow access from anywhere in the world. Having the server on your person with a UI showing who is requesting what (along with reasonable timeouts) would allow the content owner to manage requests. The requests could even come in over SMS or Twitter and then get handed over to the web server if the intents were structured correctly.

    1. That OS is based on Debian. That’s not a hack when it comes with the OS. This is about an Android device which is not intended to be able to install command-line packages.

    2. Nokia! What the heck happened there? Those guys had the best phones bar none, but they made more stupid strategic mistakes than even Novell. Insanity.

      For a while, I figured Microsoft was secretly paying the CEO’s and boards of these firms to screw up their companies. The Maemo experience was a terrible mistake – people prefer lack of crashing and “it works as a phone” to every other aspect. And the guys doing the dev work for them to get that linux package going… such a loss!
      It had so much promise – debian on a phone.
      Google just took it way from them.

      I know the carriers want total control, but given the rich feature set of the underlying hardware, I wish someone would have grabbed that guy by the throat and said “we’re going to build a very simple fixed-time-slot multitasking OS, and then gone all apple OS circa 1984 on it.

      There is nothing people are doing with android or ios that couldn’t have been accomplished much more easily by providing a simple python/your language here/basic style scripting language and a simplified permissions model.

      It’s a shame that all the spying on the user base and locking them down so that they can monetize features has shifted the market so much. We could be building cooler apps and getting them out much more quickly had they just taken the more obvious approach to raising revenues.

      But Nokia… – I feel so jilted.
      Also: “Tank, I need an opening!”

      1. The Maemo experience was a terrible mistake – people prefer lack of crashing and “it works as a phone” to every other aspect. And the guys doing the dev work for them to get that linux package going… such a loss!
        It had so much promise – debian on a phone.

        Nokia did exactly that. Nokia N9 is the phone that “just works” as a phone (it even “just works” much more than any non-Linux (Android, iOS, WinXXX) phone) and have nearly Debian inside. And yes, you can “apt-get install apache” to it.

  3. Just a note for IP discovery: don’t forget avahi/zeroconf. It’s a great solution if you’re on the same LAN (or on a bridged VPN etc.) with the device in question.

  4. If you really want to go simple..

    python -m SimpleHTTPServer

    My phone (Razr XT912) shipped with this preloaded. All I needed to make it work was a terminal emulator app that allowed me to get to a shell. Didn’t even need to be root. Its not full featured or anything, and probably not secure enough to use for hosting pages to the public internet, but for simplicity, it can’t be beat.

    1. How’s the RAZR working for ya? I’ve had my eye on it as I am looking to finally get a smartphone this fall and have always loved em. Sounds good so far. Thanks :)

  5. I actually did this with an old jailbroken iPhone for a while, because I needed something I could leave on all the time, and it worked out rather well, after getting apache (yes, proper apache), PHP and ftpd loaded onto it. No MySQL though.

  6. Pretty neat, this was one of the first things people would try out once they rooted their phones. There is a neat ssh server app so you can ssh into your phone, there is a neat web server app that enables file transfer between phone and pc through the browser – didn’t think it was too new, but cool nonetheless!

    As far as being able to take this outside the home, I faced an issue that may be carrier dependent. My phone IP is actually not public when I’m using data. It’s behind some kind of carrier NAT, which sucks but oh well

  7. At the end of the video, it was mentioned that the sensors on the Android phone could be used as well? Can they be controlled through the desktop browser? How can that be accomplished?

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.