Original Apple iPhoneOver the last month or so that I’ve had the iPhone, I have enjoyed just the original base features included with it. But, being the geek that I am, I had to extend it further… Much further.

A week or so ago, I went ahead and decided to do my “first” hacking of the iPhone. I went to the JailBreakMe.com website and followed the simple instructions and the Installer.app which is basically a “one touch” utility to install 3rd party apps and Linux ports such as PICO and a terminal program.

I was a bit surprised to find a port of Apache 1.3.37 and PHP 5.2.3 in the repository, so I went ahead, installed them both and with a little configuration using PICO (after installing and logging in through SSH), got a functional webserver with PHP support.

I created a PHPINFO() page which shows the extensions that are activated by default, which are pretty much just the core PHP functions and started thinking what to do with it…

Of course I could use it for impromptu testing of code from anywhere, showing simple mockups offline to clients one-on-one, and other things like that, but it wasn’t enough for me…

I put the thoughts on the backburner for a few days, last night I figured I’d try something new.

Here goes…

Apache/PHP was working so I decided to go ahead and copy a full PHP site with full graphics and a PHPMail script on it.

To get this all over to the phone, I TARred up just the most necessary files, filtering out anything not directly referenced (limited amount of memory on the phone for this type of stuff).

Then I FTP’ed, using NCFTP installed from the Installer.App repository, into the machine that had the TAR, downloaded and unTARred it into Apache’s document folder (/Library/WebServer/Documents).

At that point, once all the files were in the correct place and so forth, I hit the website directly on the phone (http://127.0.0.1) and it came right up and was rather speedy. I then hit it from a workstation on the same WiFi network using the DHCP assigned IP and it came up perfectly.

Ok, so far so good, the website comes up just fine locally and remotely, lets take it a few steps further.

I decided to, from work today, to VPN using PPTP built into the iPhone into my DD-WRT router at home (It has a static IP) and then proceed to port forward port 80 from the external IP to the Internally assigned VPN IP of the iPhone. Then I proceed to add a DNS entry for it…

I also VPNed into the DD-WRT over EDGE and it worked just fine as well. Of course it was MUCH slower, but still worked fine.

It really was this easy to do something that I don’t think has ever been done before with a cellphone.

NOTE: Apache was setup to just start 1 httpd instance and I believe a max of 7, which slowed stuff down a lot with a graphical site, so I set it from 1 to 10.

If anyone has questions, feel free to leave a comment and I’ll reply as soon as I can.