The Apple TV 2 is probably the Apple product which has the most potential for customization.
A product who operate with flash memory, always powered on, and always connected, with an unix based os: it was tempting to turn it to a web server... and the results are quite impressive.
Firstly, it is obviously necessary to jailbreak the Apple TV, using Seas0npass (evasi0n can also do that). Please note that if you have an Apple TV 3, it is not possible to jailbreak it, you can stop reading this post here.
Then (and this is a bit off topic), I advise you to install ATV Flash Black, which is usually free (unless you go to a well known bay located in Sweden). This wonderful package will install you on the home screen a Media application, which lets you watch all movie formats via afp and smb shares.
This is obviously much more clean than installing this disgusting crap of XBMC. After all, you do not buy an Apple TV for a rotten interface running on a buggy and painfully slow software, isn't it?
Well, the bracket is closed, we are ready, your Apple TV 2 is jailbroken, ssh access is operational and you know its IP address (if not, go to settings> network).
Do not be fooled by the length of this tutorial, it will only take 20 minutes.
1 - Secure SSH a minimum
Like all iThings, the passwords of the two users root
are set to "alpine". We cannot leave it like that.
So, on your computer in your favorite ssh console, type:
Type alpine to log in and
Then type twice an old good very secure password, and then we will also the change the one for mobile, so
retype alpine and
it will ask you again alpine, then twice again the same password, choose a different one if possible.
2 - Install everything needed for a web server
As we do not want to saturate the ram of our Apple TV, we will not install MySQL. By the way it is very complicated to use it in this environment, since our version of php does not support it, so we will use SQLite.
ssh as root on your Apple TV, then
to get the most recent versions.
apt-get install lighttpd php sqlite3 nano
Required packages will be installed, now let set this up.
3 - Check that everything is well prepared to start at boot
I will not give great details about launchd in this post, it should be the topic of a separate tutorial.
So, now ssh:
You will likely have no file containing near or far "lighttpd" in its title, which means that nothing is configured.
In this case
and copy the contents of the following file:
<?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">
ctrl + x to exit and y to save.
4 - Configure lighttpd
Check that the lighttpd.conf file is on /etc/www/
If this is not the case,
find / -name lighttpd.conf
create www in the etc folder by
then move the file
mv (old location)/lighttpd.conf /etc/www/
We will now create a folder that will contain the http directory in the root directory of the mobile user:
You can now check your config by
check the following lines:
server.document-root = /private/var/mobile/Media/Sites/
index-file.names = ( "index.php","index.html")
also check that #dir-listing.activate = "enable"
is commented with a # to avoid displaying the contents of directories.
Then configure FastCGI for PHP:
fastcgi.server = ( ".php" =>
( "localhost" =>
( "socket" => "/tmp/php-fcgi.sock",
"bin-path" => "/private/var/stash/bin/php-cgi",
"max-procs" => 1,
( "PHP_FCGI_CHILDREN" => "2",
"PHP_FCGI_MAX_REQUESTS" => "1000" ))))
then ctrl + x to close and y to save.
5 - Configure php
This is much more simple, we will do the bare minimum:
and make sure that your file looks something like this:
upload_max_filesize = 14M
post_max_size = 14M
max_execution_time = 240
session.auto_start = 1
expose_php = off
6 - Prepare a small test (optional)
Of course there is still no html or php file in our "Sites" folder, you can add them by installing netatalk or pure-ftpd, we do not need a tutorial for this.
If you really have nothing in your Sites directory, you can do a small test to verify that everything works fine:
And copy the following line:
ctrl+x and y
7 - We can start
Everything is done, we can now ask launchd to kindly start lighttpd.
launchctl load /Library/LaunchDaemons/net.lighttpd.plist
launchctl start net.lighttpd
Just to check that everything is well, do a "ps aux" and check that there is a lighttpd process.
You can now type in your browser http://(ip address of the apple tv)
7 - In case of error
If it does not work (and therefore the process lighttpd is not running when you check via "ps aux"), your config may be moldy or php crashes miserably.
First try to manually start lighttpd:
/usr/sbin/lighttpd -f /etc/www/lighttpd.conf -D
You can check error messages and you can correct what is wrong.
If the problem is php, debug is shoed by a
to check the error messages on the console.
Then, if you are still motivated, we can also configure a mail server.