How to stream music from your home iTunes library to your iPhone

Last meaningful update: 6 November 2007
Has not been updated to work with Yosemite. Or Mavericks. Or Mountain Lion (10.8). Or Lion (10.7). Or Snow Leopard (10.6). And I never actually used it myself with 10.5. Oh, and newer versions of iTunes probably break it. (At the very least, be on the lookout for your folder being named "iTunes Media" instead of "iTunes Music".) Oh, and I never checked the box labeled "collaboration" in iTunes, but if you do, it will act like "collaboration" is an artist name. Still interested? Read on...


I bought an iPhone and I'm pretty happy with it but there's one problem: it's too small to hold my entire iTunes library. I'm already using my Mac as a web server and I'm usually home or somewhere with wireless access so I figured ot a way to have all of my songs available to me at all times. I don't have much time right this second to give a lot of detail so I'll give a quick overview of what I'm doing and flesh it out later. Comments or questions can be sent to me at

Update: I fixed the script so it works if your folders have ampersands ("&") in them. Download 1.01 now.

This is pretty simple if you're already familiar with running a PHP-enabled web server on your Mac. Standard disclaimers apply: if you get your machine hacked because you're running a public websever, or if the RIAA learns that you've got all your music in a world-viewable directory, or if your ISP cuts you off for doing this, it's not my fault.

Even if you don't have a world-accessible server, you can still use this to make your music available on your wireless LAN at home or work. Just go to your computer's LAN IP address or Rendezvous name (yourcomputername.local) instead of a regular URL.

Basically, all I'm doing is making the iTunes music directory available to the web server, creating a nice start page with buttons, and then creating a directory listing. (This is done because iPhones cannot see "shared" iTunes music, nor can they connect to a shared network drive.) You can use Apache's built-in directory index feature, but what's nice about this, besides the pretty buttons on the front page (which were carefully sized and arranged to fit perfectly on the iPhone's screen, either in portrait or landscape mode), is that the listing pages themselves are sized for the iPhone, so you don't have to zoom in and out to use this.

This is still under development, so there are some problems. Some characters might cause links to fail. I haven't tested it with every type of audio file, purchased music, etc., so I'm not sure if all of those work yet. This is just a hobby for me and it does what I need it to, so updates won't be frequent.

There are also some limitations. This is not a world-class iTunes front-end. All it does is show you your music as it exists on your hard drive. There's no searching, sorting, filtering by year, playlists, etc. When you click a letter on the main screen, you'll see an alphabetical listing of artists. Clicking on an artist's name will show you an alphabetical listing of their albums. Clicking an album will show you an alphabetical listing of tracks. (These will not be in the proper album order, unless you name your songs with the track number at the beginning.) This is not searchable or sortable. All this does is give you access to any song, assuming you know where to find it.

Quick note before we get started

This might not work if you're password-protecting your music with an .htaccess file. Once upon a time it didn't work, then Apple fixed it, then they broke it again. I think it's working now but I can't say for sure.


So, let's get down to business. Here's what you'll need to do.

  1. Enable PHP.
    10.3/10.4: Download and install PHP from here. (OS X comes with Apache 1.3)
    10.5: follow the directions here.
  2. Go to System Preferences —> Sharing and turn on 'Personal Web Server.' (10.5 calls it 'Web Sharing.')
    (To verify: you should see a 'welcome' page when you launch a browser and visit http://localhost/.)
  3. Launch Terminal (Hard Drive —> Applications —> Utilities —> Terminal) and...
  4. Optional: For a bit of security, call that anything BUT 'itunes' or 'music'. If you change the name, do a find and replace on the HTML file (below) and change the links from '/itunes/' to '/whatever-you-called-it/'.
  5. Download this package (version 1.01), unzip it, and open the folder that results. (If you have any problems with it, you can get version 1.0 here.)

  6. Drop the 'iphone' folder into /Library/WebServer/Documents and drop the 'index.php' file from the 'itunes' folder into ~/Music/iTunes/iTunes Music. (Note: '~' is a Unix convention that represents your home folder. So on my Mac, '~/Music/iTunes/iTunes Music' = '/Users/brian/Music/iTunes/iTunes Music.')

And that's it! You should now be able to go to, (be sure to have a slash at the end of the address--i.e., /iphone/, not just /iphone), see the icons, and navigate to a song. When you click on a song, it will start loading, and when you press 'play', it will start to play. When you're done, press Safari's "back" button (NOT the '|<<' (previous track) button) and find another song. One nice thing is that, once the song starts playing, pressing the power button will turn off the screen but the song will keep playing.

If you have AAC files (extension: m4a) and they aren't playing, enter these four commands, one at a time, into Terminal:
For 10.3/10.4:
 sudo chmod 777 /etc/httpd/mime.types
 sudo echo "audio/mp4 mp4 m4a m4p" >> /etc/httpd/mime.types
 sudo chmod 644 /etc/httpd/mime.types
 sudo apachectl graceful

For 10.5:
 sudo chmod 777 /etc/apache2/mime.types
 sudo echo "audio/mp4 mp4 m4a m4p" >> /etc/apache2/mime.types
 sudo chmod 644 /etc/apache2/mime.types
 sudo apachectl graceful

That should make it work.

I have a demo site here. (Note: THERE ARE NO MP3s ON THIS SERVER. The links just lead to empty placeholder files.) If you're not reading this with an iPhone, you should use Firefox to look at that--Safari won't let you make the window small enough to simulate an iPhone's screen in Portrait mode.

Features to come in version 1.1

Questions? Comments? Any other feedback? Here I am.