Peter Elst

Founding Partner – Project Cocoon

iPod Touch – Apache and PHP 5.2.3

with 56 comments

When you’ve got Installer.app installed on your iPod Touch you’ll notice that it allows you to install Apache and a number of scripting languages (PHP, Perl, Python, Ruby).

That’s all well and good but getting it to run in on that local Apache install is another thing. Just managed to get it to work with PHP 5.2.3 so just follow along if you’re in the same situation:

1. Edit /etc/profile and update the line setting PATH to read as follows:

PATH="/bin:/sbin:/usr/bin:/usr/local/bin:/usr/sbin:/opt/iphone/bin"

2. Edit /etc/httpd/httpd.conf and add the following to the end of the file:

ScriptAlias /php /opt/iphone/bin
AddType application/x-httpd-php .php
Action application/x-httpd-php "/php/php-cgi"

2. Restart Apache by SSH’ing to the iPod Touch and running the following command:

apachectl restart

Now put your PHP files into the webroot (/Library/WebServer/Documents/) and access them by pointing Safari to http://127.0.0.1/<path_to_your_file>.php

I’m yet to try it with Perl and Ruby but that should just be a matter of adding another ScriptAlias to httpd.conf of your local Apache install. Enjoy!

Creative Commons License
This work, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 2.0 Belgium License.

No related posts.

Written by Peter

October 12th, 2007 at 9:38 pm

Posted in General, Mac