iPod Touch – Apache and PHP 5.2.3

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!

56 Comments

  • Pingback: shedali » Blog Archive » Home server

  • kyle
    July 5, 2008 - 1:17 am | Permalink

    im on an ipod and can’t see all of what i need to put in the PATH. Can someone post a comment with it?

  • kyle
    July 5, 2008 - 1:39 am | Permalink

    never mind

  • novemberain27
    October 27, 2008 - 4:13 pm | Permalink

    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,

  • yanus
    November 13, 2008 - 5:06 am | Permalink

    Same issue here. iPhone 3g running 2.1 cannot locate PHP package, anyone know a source where it exists ?

  • novemberain27
    November 13, 2008 - 6:37 am | Permalink

    I solved my problem. I couldnt find any repo which has the PHP and apache packages. But, I needed to install them nonetheless (since this was a part of some project work I am doing in my univ).

    So, I downgraded my iPod touch from 2.1 to first 1.1.5 (to 1.1.4 later on) and installed not only apache & php, but right now, I even have MySQL and even Drupal running on my iPod touch.

    I faced lots of difficulties through my way, installing all of them. So, I am willing to help anyone who needs help with installing Apache/php/mysql/drupal on ipod/iphone [the only pre-requisite (atleast as of now) is that a downgrade is necessary (to 1.1.5/1.1.4)]. My email is novemberain27[AT]gmail[DOT]com.

    Regards,

  • Comments are closed.

    .