Get Airplay working on Mac OsX 10.8, iTunes and iPhones, iPads, etc.

airplayHow to install Airplay on the raspberry pi for Mac OsX 10.8, iTunes and iOS 5/6.

!It’s not perfect yet, but it works. There’s a small problem if you use the 3.5mm jack output. There is some distortion when you start a new song and it’s unstable. Update juli 2013: I dont know what has changed, but the problem with distorting sound at the start is gone. Although it still has some problems when there are multiple devices connected and playing. So i still have a cronjob to restart the service every 2 hours.

Let’s make a connection to the raspberry pi with ssh, you should know how to do this. There will be a guide to get this working, although it’s not there yet.
When you’re logged in and to make things easier just type in:

Be sudo to make it easy

sudo -s

Now you’re are sudo, so dont do weird things!

Depending on which output you’re using you can use one of the following commands to select the audio output:
For the 3.5mm jack output

amixer cset numid=3 1


amixer cset numid=3 2

Change output volume with:


I’ve got mine till 86 (PCM).

To be sure you’re up to date with the latest updates type or copy:

apt-get update && upgrade

To be able to use Airplay, you need to install shairport. It’s on github, so you also need git.
There also other packages, such as avahi, so install them with the following command:

apt-get install git libao-dev libssl-dev libcrypt-openssl-rsa-perl libio-socket-inet6-perl libwww-perl avahi-utils libmodule-build-perl

To get Airplay working with Mac OsX 10.8 and iOS 6 install perl-net-sdp

git clone perl-net-sdp

Build and install with the following command

cd perl-net-sdp && perl Build.PL && ./Build && ./Build test && ./Build install

Let’s get back to the user folder:

cd ..

Let’s install shairport:

git clone && cd shairport && make install

Copy the service file for start/stop

cp shairport.init.sample /etc/init.d/shairport

Change the startup script:

vi /etc/init.d/shairport

Learn how to use Vi! Click
Change your name in the startup file:


Change access:

chmod a+x /etc/init.d/shairport

If the service doesnt show the right name try editing the following file with:

vi /usr/local/bin/

Search for my $appname with / and change "Shairport $$ on" to whatever you want.

Some people suggest making it start on boot with:

update-rc.d shairport defaults

Well, i did try that twice and it made my raspberry pi unbootable….So that’s a warning

Run Shairport with:

/etc/init.d/shairport start

Since shairport is a little buggy do the following to restart the service every 2 hours

crontab -e

Add the following line at the bottom

0 */2 * * * /etc/init.d/shairport restart

This will restart the shairport service every 2 hours

You can check wether the cronjob is working or not with:

tail -f /var/log/syslog

Check your iDevice to see the shairport 🙂

P.s. When it takes a long time to start playing music change the following:

vi /etc/avahi/avahi-daemon.conf

Change the following setting to: