Running Linux as an iTunes music server

Last night I finally got around to consolidating the household music collection and making it available to all the personal computers on our network.

I had originally shared my music on the network from my Mac, but this only worked when I was logged in and when iTunes was running. When Cat was logged in on the same machine, she didn’t have access to our music collection in my home directory.

Even if we were able to somehow share a music folder, one of us would need to remain logged in with iTunes running for any other clients on the network to have access to the library.

Fortunately, my CentOS Linux server had already been configured to backup the Mac’s iTunes music collection nightly via rsync, so it had its own mirror of what was on the Mac. I just needed to find a way to make that library available to all the Mac and PC users on my network as an iTunes share.

I discovered several approaches on the Web, but came up with a solution with a bit of custom configuration based on several resources. Now, whatever is ripped to or bought via the iTunes Music Store on the Mac is made available to all users via Apple RendezVous/Bonjour using the DAAP protocol implemented by Firefly Media Server (mt-daapd) on the local subnet.

In the steps below, corresponds to the CentOS 4.4 x86_64 Linux server, is the Mac OS X 10.4.8 running iTunes 7.0.2.

  • First, here is the nightly rsync line configured to run on the Linux server. I use keys to run the script over SSH.
    [code lang=”bash”]
    [dan@]$ vi
    rsync -av -e “ssh -i /home/dan/rsync-key” \\”/Users/dan/Music/iTunes/iTunes Music/’\’ /home/dan/iTunes[/code]
  • Install the libid3tag RPMs so that the Linux server can interpret music file metadata.
    [code lang=”bash”]
    [root@]# rpm -i libid3tag-0.15.1b-3.2.el4.rf.x86_64.rpm
    [root@]# rpm -i libid3tag-devel-0.15.1b-3.2.el4.rf.x86_64.rpm[/code]
  • Build the mt-daapd daemon from source, since there was no RPM for my platform.
    [code lang=”bash”]
    [root@]# tar xvzf mt-daapd-0.2.4.tar.gz
    [root@]# cd mt-daapd-0.2.4
    [root@]# ./configure –prefix=/usr/local
    [root@]# make
    [root@]# make install[/code]
  • Copy some example configuration files from the distribution.
    [code lang=”bash”]
    [root@]# cp contrib/mt-daapd.conf /etc
    [root@]# cp contrib/mt-daapd.playlist /etc[/code]
  • Change the default configuration.
    [code lang=”bash”]
    [root@]# vi /etc/mt-daapd.conf
    web_root /usr/local/share/mt-daapd/admin-root
    port 3689
    admin_pw admin-pw
    db_dir /var/cache/mt-daapd
    mp3_dir /home/dan/iTunes/
    servername centos
    runas dan
    playlist /etc/mt-daapd.playlist
    extensions .mp3,.m4a,.m4p,.ogg
    logfile /var/log/mt-daapd.log
    rescan_interval 300
    compress 1[/code]
  • Perform some initial setup, which shouldn’t be necessary if you are installing mt-daapd from an RPM instead of source.
    [code lang=”bash”]
    [root@]# mkdir -p /var/cache/mt-daapd
    [root@]# cp contrib/mt-daapd /etc/init.d
    [root@]# vi /etc/init.d/mt-daapd # Make some path changes for my environment
    [root@]# chmod +x /etc/init.dmt-daapd
    [root@]# /sbin/chkconfig –add mt-daapd # Configure mt-daapd to run at startup
    [root@]# chmod o+r -R iTunes # Allow the daemon to read the audio files in my home directory, in case it’s not running as me.
    [root@]# /etc/init.d/mt-daapd start[/code]
  • With that, the share was now available to the PCs and Macs on my network. To debug any other issues, I tailed the log.
    [code lang=”bash”][root@]# tail -500f /var/log/mt-daapd.log[/code]

That was basically it. I’m still working on customizing things further, and I still keep a local copy of my music on the Mac to synchronize with my iPod.

Here’s a list of resources I consulted to get things going. Google Linux iTunes Server for more.


9 Responses to 'Running Linux as an iTunes music server'

Subscribe to comments with RSS

  1. magnus said,

    10 January 2007 at 10:17 am

    Would be interesting to see how well this plays with the new itvApple TV.

  2. code said,

    09 July 2007 at 1:59 pm

    You had said “With that, the share was now available to the PCs and Macs on my network. To debug any other issues, I tailed the log.”

    Have you tried ripping or purchasing music with one of your other PCs to see if the library for the Mac and the PC are updated with the new music?

  3. Big Dave said,

    15 July 2007 at 3:26 pm


    From the description above, it looks like the server is set to share only, NOT to be used AS the library for other computers. So if you bought music on your iMac, that music would not be added to the linux server. You would have to transfer that manually. Which would be fine by me!

  4. Daniel Krook said,

    16 July 2007 at 4:06 pm

    Hello code and Dave,

    What I do is buy music or rip CDs on my Mac, then a nightly cron job automatically backs up a copy of the music from my Mac and adds it to the Linux box’s library.

    At that point, I have 2 copies of the song and if I were to browse both iTunes shares from a third computer, I would see the new song in both libraries. In the case of music downloaded from the iTunes Music Store, if this third machine is authorized, it can play the music.

    In theory, another step can be added so that any computer of the network gets updated with the latest music files from the server’s filesystem as well, if it needs a local copy instead of streaming from the network.

    If the third machine is a Mac or Linux box, just add another rsync cron job. If it is a Windows machine, you would use its job scheduling mechanism.

  5. Fritte said,

    03 August 2008 at 1:15 pm

    I bought a sonos( system some time ago and have all my music(mp3’s ripped from CD’s) stored on a NAS, and that all works fine.

    I recently got an Ipod shuffle, and happily installed Itunes on my notebook(Windows Vista) to transfer some music. I mapped the music share on the NAS and added it as a share in Itunes and waited….and waited….etc.

    Finally it finished doing whatever it was doing and I succesfully copied a few songs to the Ipod.

    Now I’ve discovered that the NAS has a built’in Itunes Server function, which I have enabled, and it shows up nicely in the Itunes application.

    So far so good(I’ll get to the point now, I promise), but I cannot figure out how to copy music from my iTunes server to the iPod.

    I’m a newbie to this whole iPod/iTunes thing and just want to ask if you know if it should be possible to copy music from my own iTunes server to an(y) iPod?


  6. Robert said,

    13 January 2009 at 5:49 pm

    Thanks for this great howto!

    Just two things I realized while setting this up:

    There is no reason to use -e with rsync if the ssh key is in the proper location.
    rsync -av… would just work fine. But if it’s already set up like this there is no reason to change it…

    I’m using rsync -av –delete, because I usually don’t want to keep the songs on the server if I deleted them locally…

  7. John said,

    08 October 2009 at 10:21 am

    Would this work with an airport and iphone remote? Right now I have to boot my pc to play music to my airport (audio output) so that I can control it via my iphone. I’ve been looking for a linux solution that would allow for this since my centos server runs nonstop anyway!

  8. Marc said,

    12 April 2010 at 2:49 am

    Was searching for a tutorial like this.. very useful.. thanks!

    While doing my search.. I came across this site. Look familiar?

  9. luckycharms said,

    18 November 2011 at 1:41 pm

    thanks for the great info! it’d be interesting to see if there was a way to allow iTunes users to choose which songs they wanted sync’d to the server (instead of copying them wholesale).

Leave a Reply