Micro Web Servers
Copyright 2011 Technoids.com



iPod Touch
How To Turn an iPod Touch®
into a 24/7 Web  Server


The following guide will help turn your iPod Touch into a
wireless optimized 24/7 Web Server with HTML PHP and SQLite

Or Add a Web Server as Just a Another Shared App

Works on iPod Touch 2G 3G & 4G Tested on iOS's up to 5.0.1

NOTE If anything goes wrong you can restore to a factory default using iTunes
Use the USB connection


Jailbreak First

Make sure Cydia is installed
Touch Cydia and install OpenSSH and AptBackup
SSH console (Putty) (Your iPad® IP) CHANGE YOUR PASSWORD !!
passwd    (default login is root alpine Note only the first 8 characters are recognized)
(Do NOT skip the above steps or the automated scripts will not work !)
Don't forget to use TinyUmbrella to backup your SHSH blobs
IMPORTANT Settings > General > Auto-Lock > Never (At least until the installation is finished)
TIP Install FusionLock from Cydia This will bypass the Slide to unlock functiom

Install Web Server ( Lighttpd PHP SQLite Nano Top  & Optionally Perl )

Step 1: Download Installation Script webitouchd.zip (Dedicated Web Server)
or  webitouchs.zip (Just Another App)      See the NOTE: Below
Unzip webitouchd.zip ( or  webitouchs.zip )
SFTP (Filezilla) webitouchd.sh ( or webitouchs.sh )   > /private/var/tmp/
Prerequisite: You must be connected to the Internet to download the necessary apps
SSH console (Putty)
cd /tmp
bash webitouchd.sh   ( or  bash webitouchs.sh )
Your iPod Touch will reboot after the install

FOR THE NON DEDICATED SERVER SETUP ONLY (webitouchs.sh)
Install Lighttpd SBsettings Toggle from Cydia for easy Lighttpd control
NOTE: it creates and loads lighttpd2.conf
To load your lighttpd.conf  SSH cp /var/etc/lighttpd.conf  /var/etc/lighttpd2.conf

Step 2: Test
Use a browser   http://xxx.xxx.xxx.xxx  (Your iPod Touch® IP)
Or locally Safari  http://localhost 
SFTP (Filezilla) your web files to the document root   /private/var/www
( delete or over write the default index.html test file )

Step 3: See Carrier IQ re iqagent.plist

NOTE: webitouchd.sh is for a Dedicated Web Server ONLY
           ( Frees Up  More Ram Compared to webitouchs.sh )

           webitouchs.sh is for a Installing a Web Server as Just Another Shared App
           and Does Not Install The Lines & Lines  ( See Appendix - lighthttpd.conf  )

Optional Perl Install: Download perlinstaller.zip
Unzip perlinstaller.zip
SFTP (Filezilla) perlinstaller.sh   > /private/var/tmp/
SSH console (Putty)
cd /tmp
bash perlinstaller.sh

<== Install Apps
<== Create Folders
<== Unload Unnecessary
       Processes

Appendix

Testing Any lightttpd.conf Changes
lighttpd -t -f /etc/lighttpd.conf   (Test the lighttpd.conf)
lighttpd -f /etc/lighttpd.conf      (load lighttpd manually)
killall lighttpd                         (Restart or Stop lighttpd if Plist 1 & 2 Not Used)

Manual Installation
SSH console (Putty)
apt-get -y install top
apt-get -y install nano
apt-get -y install php
apt-get -y install lighttpd
apt-get -y install wget
apt-get update
apt-get -y upgrade
mkdir /private/var/www
chown root:wheel /private/var/www
mkdir /var/log/lighttpd
chown root:wheel /var/log/lighttpd
launchctl unload -w /System/Library/LaunchDaemons/com.apple.syslogd.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.DumpPanic.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.ReportCrash.DirectoryService.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.ReportCrash.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.ReportCrash.Jetsam.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.ReportCrash.SafetyNet.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.ReportCrash.SimulateCrash.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.ReportCrash.StackShot.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.racoon.plist    (Used for VPN Do not unload if using proxy service)
launchctl unload -w /System/Library/LaunchDaemons/com.apple.AdminLite.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.mobile.profile_janitor.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.aslmanager.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.powerlog.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.chud.chum.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.chud.pilotfish.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.apsd.tcpdump.en0.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.apsd.tcpdump.pdp_ip0.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.marco.tcpdump.en0.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.MobileInternetSharing.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.mobile.obliteration.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.AddressBook.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.voiced.plist
launchctl unload -w /System/Library/LaunchDaemons/com.saurik.Cydia.Startup.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.locationd.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.fairplayd.*.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.mediaremoted.plist
launchctl unload -w /System/Library/LaunchDaemons/com.bigboss.sbsettingsd.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.AOSNotification.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.tcpdump.server.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.VoiceOverTouch.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.gamed.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.searchd.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.scrod.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.livetrace.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.itunesstored.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.dataaccess.dataaccessd.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.accessoryd.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.midiserver.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.mDNSResponderHelper.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.itdbprep.server.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.gmmd.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.sharktrace.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.apsd.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.printd.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.mobile.storage_mounter.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.datamigrator.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.UIKit.pasteboardd.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.mediacontrold.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.daily.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.search.appindexer.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.CommCenterMobileHelper.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.CommCenterRootHelper.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.marcoagent.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.iapd.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.mtmergeprops.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.managedconfiguration.mdmd.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.managedconfiguration.profiled.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.mobile.installd.mount_helper.plist


SFTP (Filezilla) Transfer the config files ( file contents are below )
lighttpd.conf          >  /private/etc
mod_fastcgi.conf   >  /private/etc
php.ini                  >  /usr/lib
404error.html        >  /private/var/www
(Plist1) com.http.lighttpd.plist   >  /Library/LaunchDaemons
(Plist2) com.http.lighttpd.plist   >  /System/Library/LaunchDaemons

SSH console (Putty)
reboot


<== Do Not Unload These
       Processes If You Want
       Full Functionallty
      (Dedicated Server Only)

<== Do Not Copy These
       Plists If You Want To
       Control Lighttpd Manually

Plist1
com.http.lighttpd1.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>lighttpd</string>
    <key>OnDemand</key>
    <false/>
    <key>Program</key>
    <string>/usr/sbin/lighttpd</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/sbin/lighttpd-angel</string>
        <string>-f/etc/lighttpd.conf</string>
        <string>-D</string>
    </array>
</dict>
</plist>

Plist2
com.http.lighttpd2.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
   <key>Label</key>
   <string>com.http.lighttpd</string>
   <key>ProgramArguments</key>
   <array>
       <string>/usr/sbin/lighttpd</string>
      <string>-f</string>
       <string>/etc/lighttpd.conf</string>
   </array>
   <key>RunAtLoad</key>
   <true/>
</dict>
</plist>

php.ini ( As Dedicated Server )

memory_limit = 64M
mod_fastcgi.conf

fastcgi.server = ( ".php" =>
( "localhost" =>
(
"bin-path" => "/usr/bin/php-cgi",
"socket" => "/tmp/php.socket"
)
)
)
404error.html

<html>
<head>
<title>Page Not Found</title>
<meta http-equiv="refresh" content="0;url=/">
</head>
<body>
</body>
</html>
Configuration Files

webitouchd.zip


webitouchs.zip


Dedicated Web Server

Shared Web Server

uninstaller.zip


Uninstaller

lighthttpd.conf    NOTE If you do not want server logs remove lines

include "mod_fastcgi.conf"
server.document-root = "/var/www/"
server.port = 80
server.errorlog  = "/var/log/lighttpd/error.log"
accesslog.filename  = "/var/log/lighttpd/access.log"
server.modules              = (
            "mod_access",
            "mod_accesslog",
            "mod_fastcgi",
            "mod_cgi",
            "mod_compress",
         "mod_evasive"
)
url.access-deny = ( "~", ".sqlite" )
evasive.max-conns-per-ip = 10
cgi.assign                 = ( ".pl"  => "/usr/bin/perl")
compress.cache-dir         = "/tmp/"
compress.filetype          = ("text/plain", "text/html")
server.tag = "Technoids.com"
server.name = "Technoids.com"
server.pid-file = "/var/run/lighttpd.pid"
index-file.names = ( "index.html",  "index.php")
server.error-handler-404 = "/404error.html"
server.max-fds = 256
server.kbytes-per-second = 120
connection.kbytes-per-second = 32
mimetype.assign             = (
  ".pdf"            =>      "application/pdf",
  ".swf"            =>      "application/x-shockwave-flash",
  ".zip"            =>      "application/zip",
  ".mp3"          =>      "audio/mpeg",
  ".wav"          =>      "audio/x-wav",
  ".gif"            =>      "image/gif",
  ".jpg"           =>      "image/jpeg",
  ".png"          =>      "image/png",
  ".css"          =>      "text/css",
  ".html"        =>      "text/html",
  ".htm"         =>      "text/html",
  ".js"           =>      "text/javascript",
  ".ico"         =>      "image/x-icon",
  ".txt"          =>      "text/plain"
)



perlinstaller.zip


Perl Installer

php.ini ( As Shared Server )

memory_limit = 10M
Running > iOS4.2.1
Read This !