Micro Web Servers
How To Turn an Apple® TV 2G
into a 24/7 Web  Server



The following guide will help you jailbreak an Apple® TV 2G and turn it into an
optimized 24/7 Web Server with HTML PHP and SQLite ( ethernet or wireless )

NOTE If anything goes wrong you can restore to a factory default using iTunes
Use the USB connection without the power cable plugged in for a restore







Jailbreak Apple® TV 2G iOS 4.2.1
(For iOS 4.3.1 or 4.4.4 see Jailbreak then proceed to Step 6)

Download GreenPois0n RC6.1 for Mac or Windows
The Mac version is a lot easier to use than the Windows version

Step 1: Run GreenPois0n and click “Yes” when it prompts for jailbreaking Apple TV

Step 2: Connect your Apple® TV 2G to your computer using a micro USB cable
Windows version: Click on “Prepare to Jailbreak (DFU)”  Goto Step 3:
Mac Version: Follow the on screen instructions Keep the power plugged in Skip Step 3:

Step 3: Windows Version (Continued) Follow the following onscreen instructions to enter DFU mode:
     Plug the Apple® TV in to a USB port (Wait 7 seconds)
     Plug in the power adapter (Remove after 3 seconds)
     Press and hold MENU and PLAY (7 seconds)
     Release both buttons

Step 4: GreenPois0n will start “Jailbreaking” the Apple® TV 2G. The process will take 3+ minutes to complete on a PC (less then a minute on Mac). Leave it plugged into the USB for 1+ minutes before disconnecting it.

Step 5: Your Apple® TV should now be successfully jailbroken. Once done, unplug the USB from your computer and connect your HDMI TV/monitor. Navigate to “greenpois0n” menu and select “Inject Software” option to install Cydia package. Make sure you have it connected to the Internet with the ethernet cable.
(To reboot navigate to nitoTV > Settings > Reboot AppleTV)

Step 6: SSH console (Putty) (Your Apple TV® IP) CHANGE YOUR PASSWORD !! passwd
(default login is root password is alpine) Note only the first 8 password characters are recognized

***(Don't forget to use TinyUmbrella to backup your SHSH blobs)***

Step 7: See Carrier IQ re iqagent.plist


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

Step 1: From your TV/monitor HDMI Console
General > Sleep After = Never
Settings > Screen Saver > Start After = Never
Settings > Airplay = Off
nitoTV > Settings > AppleTV Updates = Disabled
nitoTV > Install Software > OpenSSH
Optional: Change the Name of the TV -   Settings > General > Name
Optional: Wireless Settings - General > Network > Wireless > Configure Wi-Fi ( unplug the ethernet cable first )
Optional: Set TCP/IP as fixed -  Settings > General > Network > Configure TCP/IP > Manual
Write down your IP
nitoTV > Settings > Reboot AppleTV
Note: Only the Wireless or Ethernet can be used at once - If the ethernet cable is plugged in it disables the wireless

Step 2: Optionally Change Time Zone from default PST - SSH console (Putty)
rm /private/var/db/timezone/localtime
cd /private/var/db/timezone/
ln -s /usr/share/zoneinfo/Canada/Eastern localtime
( Note replace Canada/Eastern with your time zone To find your time zone  cd /usr/share/zoneinfo/     ls )

Step 3: Download Installation Script webtv2g.zip
Unzip webtv2g.zip
SFTP (Filezilla) webtv2g.sh > /private/var/tmp/
Prerequisite: The Apple TV must be connected to the Internet to download the necessary apps
Hint: The TV/monitor console will ony display a no connect message if its not connected to the Internet
SSH console (Putty)
cd /tmp
bash webtv2g.sh
Your Apple® TV will reboot after the install

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

Step 4: Test
Use a browser   http://xxx.xxx.xxx.xxx  (Your Apple TV® IP)
SFTP (Filezilla) your web files to the document root   /private/var/www
( delete or over write the default index.html test file )


NOTE:
Console Menus That are Removed - Computers - Internet -  Movies - TV ( Not needed for Dedicated Server Only )
Video playback and the Web Server can be run together but the web server will have less available memory
To Restore These TV Console Menus For Video Playback SSH console (Putty)
launchctl load -w /System/Library/LaunchDaemons/com.apple.airtunesd.*.plist (Only needed for Movies)
launchctl load -w /System/Library/LaunchDaemons/com.apple.fairplayd.*.plist  (Only needed for Movies)
cd /Applications/AppleTV.app/Appliances
mv Movies.frappliance.old Movies.frappliance              (Movies)
mv TV.frappliance.old TV.frappliance                          (TV)
mv Internet.frappliance.old Internet.frappliance            (Internet)
mv Computers.frappliance.old Computers.frappliance  (Computers)
killall AppleTV


HINTS:

Filezilla
After you upload or download files hit F5 to see the folder and or file changes

Lighttpd Logs
If you delete the error.log or access.log in the /var/log/lighttpd/ folder you must restart Lighttpd for them to be recreated
<== Install Apps
<== Create Folders
<== Unload Unnecessary
       Processes
Do not unload these 2 lines if you want to rent Movies
Appendix

Testing Any lightttpd.conf Changes
lighttpd -t -f /etc/lighttpd.conf  (Test the lighttpd.conf)
killall lighttpd                         (Restart lighttpd)

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 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.airtunesd.*.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.fairplayd.*.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.locationd.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.syslogd.plist
launchctl unload -w /System/Library/LaunchDaemons/com.saurik.Cydia.Startup.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.OTACrashCopier.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.ReportCrash.StackShot.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.racoon.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.AdminLite.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.mobile.obliteration.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.MobileInternetSharing.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.livetrace.plist
launchctl unload -w /System/Library/LaunchDaemons/com.apple.mobile.profile_janitor.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.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

Items Needed


Apple TV 2G (Does not come with a micro USB cable)
  

Micro USB cable (A BlackBerry USB cable works perfectly)
Also needed - one HDMI to HDMI or HMDI to DVI cable
Filezilla   or
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 = 24M
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"
)



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>

Copyright 2011 Technoids.com


Configuration Files

webtv2g.zip

Dedicated Web Server
Installer

uninstaller.zip


Uninstaller

perlinstaller.zip


Perl Installer

How To Videos:
Jailbreak & Backup
SHSH blobs
Running > iOS4.2.1
Read This !