I’ve turned my old iPhone 3G into a mobile Web server running MySQL, PHP and lighttp with WordPress! (see screenshot)
Step 1: Jailbreak
Jailbreak the thing. You need the freedom to fiddle deeper into the phone than Apple is interested in you fiddling. As of November 2013, an iPhone 3G running iOS 4.2.1 is fairly old and finding a web page with instructions and working links to software isn’t so easy. In fact, this was the hardest part of the process!
The jailbreak process uses a piece of software to get around Apple roadblocks and allow you to install non-Apple Store software on your phone. Doing this will VOID THE WARRANTY on your phone, if you still have one. You only want to do this if you’re the kind of a person who takes things apart and doesn’t mind if you break them while doing so.
Thoroughly warned??? Ok then, let’s get started.
First off, you’ll need a piece of software called “redsn0w“.
Where to download Redsn0w: http://www.iphonehacks.com/download-redsn0w
For my phone I chose Redsn0w 0.9.10b8b. It’s possible a newer version would work, but I couldn’t seem to get a definitive answer. This one worked for me. You also need a file that describes the hardware of your particular device. (It appears newer versions of Redsn0w now download this directly from Apple, but older versions require you have it on hand.)
I found a copy linked from this page: http://osxdaily.com/2010/11/22/ios-4-2-direct-download/
- Plug your phone into your computer.
- Now run Redsn0w.
- Choose “Jailbreak and install Cydia” and follow the instructions.
If all goes well your phone will reboot and you’ll see you have a new app called Cydia that lets you install non-Apple software.
Note: if you want to “unlock” your phone from your provider network, there’s another tool called Ultrasn0w which does this. I haven’t tried it.
Step 2: SSH
First, let’s SSH from your computer to your iPhone.
- open Cydia
- install OpenSSH
- find your phone’s IP address
- SSH to that address with user: root and password: alpine
Now you rule your phone!
Step 3: Get all the softwares
Fortunately, someone’s done the real work for you. You can get it all in one package: PHP, MySQL and Lighttpd through Cydia.
- Tell Cydia where to find the software by giving the following command in SSH:
- echo ‘deb http://ios-webstack.tk/cydia/ ./’ > /etc/apt/sources.list.d/ios-webstack.list
- Start Cydia
- Search for “touch-lighttpd-php-mysql” (for iPad or Apple TV see here)
- Heck, why not reboot the phone
Now when you point your browser to your phone’s IP address you’ll get a message letting you know it’s working. Here’s what it looks like:
To actually *do* anything with this you’ll need a text editor. Both of these you can install through Cydia:
- A version of Emacs called Mg: http://en.wikipedia.org/wiki/Mg_(editor) (I had trouble with this crashing)
- Nano: http://forums.macrumors.com/showthread.php?t=1061129
- Once you start looking, a surprising amount of *nix software is available through Cydia – check it out!
If you’ve gotten this far you can probably take it from here. Some other things I’ve learned in the short time I’ve had this up and running:
- Web root is /var/www
- http://your_ip_addr/adminer.php?server=localhost will give you a web GUI for running MySQL commands if you don’t like to do that from the command line. You can also use Cydia to install phpmyadmin.
- scp is a handy way to get files to and from your new phone-based server.
- If you let your phone go into one of the sleep modes, your server stops responding. Oops. Watch your battery.
- I setup a working WordPress server, and then changed networks. Different IP, WordPress stops working. Oops. Another thing to watch out for.
Step 4: Now what?
That was very gratifying, but what to do with this new portable, battery powered web server? My suggestions:
- Location based, pirate inter-webs. Perhaps you can’t get permission at work to run a server and you have no place to hide a beige box. Well, pretty easy to hide your phone! Share the IP with your work chums and you can post funny photos of the boss on your own private Facebook.
- Off-the-net inter-webs. Perhaps say, you’re at Burning Man. You can’t get out to the greater network anyway, but you could have your own, without even needing a generator to run the equipment! The iPhone has no moving parts – nothing to get gummed up with playa dust. Now you’ve got your electronic camp info-hub. Post the address and give the kiddies something to do with their smart phones.
- Run your own off-the-grid instant messaging service. This is one of the things I’m personally working on setting up using this: https://www.erlang-solutions.com/products/mongooseim-massively-scalable-ejabberd-platform
- More ideas? Send them to me here at email@example.com!