Using PHP and a Shell Script to Restart an AppleTV remotely — via the web

As a follow up to my previous post, here’s how to do the same thing, but from a web browser (say, on your iPhone) — it assumes you’ve already written a shell script, as discussed earlier.

  • Configure Apache to run PHP on your Mac (these instructions are for Leopard, but similar ones are out there for Tiger)
  • Configure Apache to run as your own user, instead of the WWW user — a serious security risk. Only do this on an internal network! The WWW user won’t have adequate permissions to do what we need to.
  • Put this .php page in your /Library/WebServer/Documents/ folder as RestartMedia.php — you’ll need to supply your own image file in the same path as well.
  • Visit http://yourcomputer.local/RestartMedia.php from a browser. Clicking on the text or image will execute a shell script located at: /Applications/Automation/RebootMediaServers.sh

Obviously you can customize this at will, including file locations. This was just a quick hack that does the job for me — and the webpage is optimized for Mobile Safari.

Leave a Reply

Your email address will not be published. Required fields are marked *