This was one of my first popular iPhone/Tech posts… Reposting it now about 16 years later. 🙂
Over 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/nano 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/nano (after installing and logging in through SSH), got a functional web server 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 and 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 TAR’ed 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 unTAR’ed 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 had a static IP) and then proceeded to port forward port 80 from the external IP to the Internally assigned VPN IP of the iPhone. Then I proceeded to add an external DNS entry for it. Changing my A record from a “REAL” server IP to my home IP redirecting to my iPhone. Which was at work with me, connected to home via VPN and so on. Quite a connection.
I also tested VPNing into the DD-WRT router over EDGE (Pre-3G) 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. (At the time of this article)
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.
thanks for the tips, got it working on my iPod Touch
any idea why "preg_replace" is not working?? Always returns null string…
$str = "this is a test";
$str = preg_replace( '/is/', "is not", $str );
print $str;
I haven't used preg_replace, so I'm not sure. I know at my day job last week, I was trying to use the "gregoriantojd" function and it just WOULD NOT work. After a bit of research, the calendar functions ended up not being compiled into PHP. After a quick recompile, it worked fine. Might be a similar issue.
I know the Apache/PHP for the iPhones is pretty minimal feature-wise.
The regexp functions are pretty basic, however. If I give bad parameters for the function, it complains as it should, implying that the function really is there… just not working. There's probably a compile time setting that is set differently from all of the other installs of PHP that I've tried this on.
hello im using dd-wrt im wondering if u can make howto how to setup vpn on iphone and settings on dd-wrt.. or if u can email the settings so i can setup my
Can you please tell me how you configured PHP in the httpd.conf? i didn´t get it working, always getting Internal Server Error…heres my config from now:
Options ExecCGI
AllowOverride None
ScriptAlias / /opt/iphone/bin/
Action php-script /php
AddHandler php-script .php
I stupidly upgraded to 1.1.2 and my phone is wiped… It wasn't that hard though, it's all out there on the net, just google around. I'm sure you found my site with Google, you'll find a more detailed instructional elsewhere I'm sure…
Thanks for the visit to the site though.
Is there any way to run Mysql server on IPHONE?
I don't think MySQL has been ported yet, although It would be nice…
I am trying to set up PHP and Apache on my Ipod Touch. I have the apache working, but I do not know where to set up the PHP. I get a "Method not allowed" error when I submit a form through POST to a PHP page.
I installed SSHD onto my phone and SSHed into it and followed instructions posted on other websites…
There is a little configuration that has to be done to get Apache and PHP working together nicely…
Sorry I can't be of more help, but it's been a while since I did this and since then I've upgraded to 1.1.4 and am no longer jailbroken.
Good luck.
How do I make my iphone without cell service into a wifi web server?
You can Google around about activating it without service, then you only need to JailBreak it (again Google), and install the Apache web server using the installer.app … As stated above, it is good to install the SSH Daemon on it to configure it.
Hi
I tried to install Apache and PHP on my iPhone using installer/app but they were not there.
I knew they were supposed to be in network and development but I didn't find them. Any idea?
Thats superb, you can essentially take a portable web server anywhere! Or if you were a chef could have a mysql databse of recipes and carry them around in your pocket!
I wish there was a light weight MySQL for the iPhone. (I haven't looked lately) It would definitely open the door for a really cool apps. I believe SQLite is already on the phone, but that's a big learning curve for those of us who are most used to MySQL. Of course you can just simply write a remote app to access it via EDGE or WiFi.
I have written a small online iPhone app for Real Estate Agents/Brokers that I'm tweaking for public use.
I tried to install the tiff from jailbeakme site, the safari just frozen and one question mark appear, then I use desktop browser to link the file url, it is /files/y.tiff, my antivirus software report backdoor alert.
Dude, this article is way old… JailBreakMe.com I don't think works anymore for any of the new versions of the iPhone. I haven't used it since version 1.1.1 and now we are on 2.1
The method used to originally jail break the phone was a "malformed" TIFF file that IS technically a "backdoor" into the phone. That's why it got flagged in your AV program.
Google around elsewhere and you'll find the current software used to Jailbreak iPhones.
Hi,
I have ipod touch (2.1) and I have jailbroken it (using quickpwn).
I want to install apache and php on the device, but i cannot find the packages in the installer (i am using installer 4 beta).
I have tried to add several other repos in the sources, but havent been able to find the packages in any of them.
What should I do?
Can anyone tell me some repo which has those packages, so that i can add it.
thanks & regards,
Just wanted to add that Pocket PC (Windows Mobile) 2002 Phones could use a Microsoft made HTTPD server software from the SDK that supported ASP server-side scripting and ADOCE database access..and that was way back in 2001, 7 years ago 😉
Hi All,
novemberbrain27:
I've got the same problem – where the hell is Apache or PHP?, I'm using Installer 4.0b10-3 and can't find them anywhere!
I did find and install Lighttpd however and after a lot of fu%&!^*ing around I have managed to get that working. Now if only I can get PHP & SQLite cranking!
If anybody knows how to install php onto IPhone without all the compiling stuff, or the whereabouts of PHP in Installer or Cydia, could you please let us wannabe hackers know!
YesWeCan:
I hava HTC Universal now running Windows Mobile 6.1. I agree with you wholeheartedly – I've have Microsoft HTTPD serving up asp pages connected to pocket access databases & PocketHPH running php pages connected to sqlite databases – been doing so for a number of years now!
Come on IPhone, pull your finger out! You have the hardware/OS to do it!, Steve Jobs, what's with the lame Bluetooth support!
Many thanks to all you hard working developers, jailbreak app makers & 3rd party repomen!
Great post, thanks for sharing.
How do you add apache and php to repositories of install.app – I can't seem to find it. Can I go in through SSH and do this?
I haven't used installer.app in a long time. I went 3G and haven't jailbroken it yet.
From what I remember from a year or so ago was that you could add the repos right from the handset. Perhaps that has changed. Not sure.
Please please please tell me where you got Apache (the exact URL). I can't find it in any of the Community sources under installer.app or under any of the repositories under Cydia. I have used Google on my PC but …
Also, if you know where I can Perl for the iTouch …
not to be a downer, but is it really practical? I've been looking at gumstix (as mentioned above) for a while. I think portable personal server for developing on the go would be cool, or even just opening the doors for you to write simple programs (html) that you could access locally, but with a live server, what if you get dugg or slashdotted, even while you're having a phone call? and with WiFi, 3G etc why would you want an unplugged webserver in your pocket that might run out of juice at any time. Wouldn't it make more sense to leave the serving to the server and be the client on your device?
I'm sure that with 3G you're already carrying a homing device in your pocket, so maybe no effect in that sense. I could imagine some security issues where you may be able to be found based on your IP if someone was clever enough, or if someone sent a ton of packets to your server and DOS'd your phone..
i need to read more science fiction!
Dude, of course it's not practical… It was just done to prove it was possible. hehe. And no one would know where I am because I did it through a VPN that wasn't in any way connected with the AT&T Phone service.
More than anything, it could be useful to load mockup static HTML pages to show a website to a client or something as if it were on a "live web server".
If possible, can you do a video tutorial on this topic. Thanx.
Nope. I did this a LONG time ago. I don't even have a jail broken iPhone anymore. If I ever get around to doing something like this again, I may try and do a video.
Thanks for your interest.
Hola amigo donde puedo conseguir lo de php para el iphone, ya que los links estan rotos y solo pude conseguir el mysql gracias y le intentare ….
Tienes que tener una "jail broken" iphone para poder hacer todo lo mencionado en el artículo. No he hecho esto por mucho tiempo, así que ya no contar con información actualizada sobre la manera de hacerlo.
I have not got Installer.app, but Cydia and Rock on my iTouch 3.1.2
Where can i download it (what is the repo-url?)
This original article is very old… I'm sure things have changed greatly since I wrote it.
I still have my iphone but it is not jailbroken at the moment. Might want to keep googling around.
Good luck.
I too am looking to put the Apache and PHP on my iPod 3g but I have googled for days and can not find the file … do you remember the file name or what repository it was in so it can be added to Cydia?
Some one out there HAS to still have that file, I can manually SSH it in if I have to.
I need it so I can put the PDF of my Calculus book in the iPod and be able to refer to sections in class … the iPod is about 1,000 times lighter than my Calculus book!
To solve this simply install PHPod from Cydia and it will install lighttpd, apache and sqlite!
haha nice one with that VPN access over edge!
Here's my edition of setting things up: http://niftyhomeautomation.tumblr.com/