Micro Web Servers
Copyright 2011 Technoids.com



iPad
How To Install  a Web Server
on an iPadŽ


The following guide will help you install a web server on your iPad

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

Works on iPad & Tested on iOS's up to 5.0.1

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


Install Web Server ( Lighttpd PHP SQLite Nano Top & Optionally Perl )
IMPORTANT Settings > General > Auto-Lock > Never (At least until the install is finished)

Step 1: Download Installation Script webipads.zip
Unzip webipads.zip
SFTP (Filezilla) webipads.sh   > /private/var/tmp/
Prerequisite: You must be connected to the Internet to download the necessary apps
SSH console (Putty)
cd /tmp
bash webipads.sh 
Your iPad will reboot after the install

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 iPadŽ IP)
Or open 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: webipads.sh is for a Installing a Web Server as Just Another Shared App
           and Does Not Install The Lines  ( See Appendix Lighttpd.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 Installed)

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


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


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

memory_limit = 10M
lighthttpd.conf    NOTE If you want server logs add these 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"
)
url.access-deny = ( "~", ".sqlite" )
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
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"
)



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

webipads.zip


<== Loads Web Server on
       reboot and keeps it loaded

Shared Web Server

uninstaller.zip


Uninstaller

perlinstaller.zip


Perl Installer

Running > iOS4.2.1
Read This !