Install your own Web Server


Aim

You will get a well running Lighttpd - PHP - MySQL webstack on your AppleTV / iPad / iPhone.

Requirements

  • A jailbroken iOS Device.
  • Knowledge about the security risks of the Wild Wide Web.


Add the iOS WebStack Cydia Repo Source

You will find all the iOS WebStack project packages here: http://ios-webstack.tk/cydia
You can add the repo source in Cydia or in NitoTV. ATV2 users can also use following shell command:

echo 'deb http://ios-webstack.tk/cydia/ ./' > /etc/apt/sources.list.d/ios-webstack.list
apt-get update


For your security I advice you to:

  • add the GPG public key of the iOS WebStack repo (HOWTO)
  • update/upgrade your Cydia software parts cyclically



Install iOS WebStack on Apple TV

Apple TV Preparation

If not done yet and if it is possible, please symlink the folder /usr/local to /var/stash/local.
Through that the package data are not stored on your small first ATV flash partition:

  • check it
ls -l /usr
  • move the content and create the symlink
mkdir /var/stash/local
cp -ra /usr/local/* /var/stash/local
rm -r /usr/local
ln -s /var/stash/local /usr/local 

Install (on Apple TV)

  • Add http://ios-webstack.tk/cydia to your Cydia Sources (see here)
  • Install the Cydia package atv-lighttpd-php-mysql:
apt-get update
apt-get install atv-lighttpd-php-mysql

(If you got dependency errors, please have a look here: http://forum.firecore.com/topic/9565)

Daemonize (on Apple TV)

  • After the installation the Lighttpd and MySQL server are already running.
  • The servers are running as Daemons.
  • After a server daemon is killed, it will restart automatically through the daemon launcher.
  • You can restart the server with the 'killall' command (cydia package: shell-cmds)
    killall lighttpd
    killall mysqld

Daemon Launcher (on Apple TV)

The servers are running as long as the Daemon Launcher Services are active (even after a reboot).

If you would like stop the Daemon Laucher Services, please use following commands:

launchctl unload -w /Library/LaunchDaemons/com.atv.lighttpd.plist
launchctl unload -w /Library/LaunchDaemons/com.atv.mysql.plist

If you would like start the Daemon Laucher Services, please use following commands:

launchctl load -w /Library/LaunchDaemons/com.atv.lighttpd.plist
launchctl load -w /Library/LaunchDaemons/com.atv.mysql.plist


Now you can open http://IP_OF_YOUR_ATV

Install iOS WebStack on iPad/iPhone

Cydia Preparation

To see the iOS WebStack packages in Cydia you have to categorize your 'User behavior'.
Please open Cydia and then:

  • at the bottom 'Manage'
  • at the top 'Settings'
  • then choose 'Hacker' or 'Developer'

Install

  • Add http://ios-webstack.tk/cydia to your Cydia repo sources
  • Search the Cydia package ios-lighttpd-php-mysql and install it.
  • After the installation the Lighttpd and MySQL server are not running.
  • You have to start the server manually in your settings.
  • Open your Settings and then tap on Lighttpd MySQL to switch ON the server.
  • Now you can start Safari on your iOS device and open http://localhost
    (Don't use Chrome or similar, it could be you get in trouble with login screens.)



Finishing (all devices)

Setup MySQL

After the installation you have to do two steps

  1. Clean up your MySQL database
  2. Set a fresh MySQL root user password

The already pre installed PHP-Script Adminer will help you to do that.

If you open a web browser and if you then open the following site http://IP_OF_YOUR_ATV or http://localhost , you will get all necessary information. Please do it as described. Otherwise, hacker will love your device.

Web Content

After the installation you will find and you can place your web content here: /var/www .
For Lighttpd the owner settings of /var/www must be 'daemon:_www'.

Change passwords for user 'root' and 'mobile'

It is very important that your jailbroken iOS Device does not use the default passwords for the system users 'root' and 'mobile'. The following video show you how you can change the passwords: http://www.youtube.com/watch?v=vQdCrCzPOL0

Setting up a Lighttpd SSL configuration

Setting up a MySQL SSL configuration

You need more technical information or the whole source code?