AirPi: DIY Airplay Speakers using Shairport and a Raspberry Pi

We have speakers in all the ground floor rooms of our house, all driven from the same amp. It’s neat but controlling the input requires going back to the amp.

Surrounded by iDevices too and with apps like iPlayer, Spotify and home share on iTunes, being able to throw audio to the speaker system had to be done. Que Airplay, however, this requires a nice Airplay amp or getting an AirPort. I then found out about Shairport, a program that emulates an AirPort’s Airplay function. With a Raspberry Pi kicking around, I had just found its new job.

Quite a lot has changed in the year since I did this and rather than try and add more updates to this, I have run through the process again and created a new tutorial.

Setting Up Arch ARM

I opted for the Arch Pi distribution for this, simply because it is my Linux of the moment and with no window manager, is perfect for a standalone device. The first thing you’re going to want to do is a system update with pacman (you’ll probably need to update pacman on first run so need to do this twice).

pacman -Syu

Next you’ll need to install the tools required to compile in Arch.

pacman -S kernel26-headers file base-devel abs

Then git to clone the Shairport repo.

pacman -S git

Shairport has a number of dependencies so we’ll install them and there dependencies too.

pacman -S avahi libao openssl perl-crypt-openssl-rsa perl-io-socket-inet6 perl-libwww

Finally, alsa is required to get sound output in Arch on the RPi. Install this and then load the sound driver using modprobe.

pacman -S alsa-utils alsa-oss
modprobe snd-bcm2835

Alsa mutes the channels by default so open the mixer and raise the volume to 0dB gain. Test the output using speaker-test.

speaker-test -c 2

I’m using the 3.5mm jack as an audio output and at this stage I failed to get audio. I realised that with the HDMI plugged in, audio was going through that and not through the jack (it doesn’t seem to do both at once). You need to disconnect the HDMI and reboot the RPi. If you’re connected via monitor and want 3.5mm jack, there is no option but to continue via ssh or use the phono. I was doing it all via ssh so it didn’t really matter. If you do reboot, don’t forget to reload drivers using modprobe before testing again.

update: you can change output with using amixer cset numid=3 ]

If all is good, save the alsa levels.

alsactl store

And set the sound modules and new daemons to load at startup by editing /etc/rc.conf

vi /etc/rc.conf
MODULES=(.. snd-bcm2835 ..)
DAEMONS=(.. dbus avahi-daemon alsa ..)

Probably a good idea to reboot at this stage.

shutdown -r now

Make Shairport

Make a directory called Shairport in the home folder.

mkdir shairport

Now clone the repo, cd into it and make.

git clone shairport
cd shairport

All being well, Shairport should have built and you can now run it with the name ‘AirPi’.

./ -a AirPi

Create daemon

18/12/12 – This may not work now due to Arch builds now using systemd. If it doesn’t, this comment thread has a solution.
Install the new build

make install

Shairport includes a sample init file but it is not designed for Arch. Arch includes a template for creating new daemons in /usr/share/pacman/rc-script.proto, first copy to /etc/rc.d

cp /usr/share/pacman/rc-script.proto /etc/rc.d/shairport

Now edit the file using vi as mine below


. /etc/rc.conf
. /etc/rc.d/functions

get_pid() {
    pidof -o %PPID $daemon_name

case "$1" in
        stat_busy "Starting $daemon"

        if [[ -z $PID ]]; then
            [[ -f /var/run/$ ]] &&
                rm -f /var/run/$
        # RUN
        $daemon_name -d -a AirPi
        if [[ $? -gt 0 ]]; then
            exit 1
            echo $(get_pid) > /var/run/$
            add_daemon $daemon_name
            exit 1

        stat_busy "Stopping $daemon_name daemon"
        # KILL
        [[ -n $PID ]] && kill $PID &> /dev/null
        if [[ $? -gt 0 ]]; then
            exit 1
            rm -f /var/run/$ &> /dev/null
            rm_daemon $daemon_name

        $0 stop
        sleep 3
        $0 start

        stat_busy "Checking $daemon_name status";
        ck_status $daemon_name

        echo "usage: $0 {start|stop|restart|status}"

exit 0

# vim:set ts=2 sw=2 et:

Add shairport to the list of daemons in etc/rc.conf and you’re all good to go.


I’ve since found a command to redistribute the Pi’s memory, providing less dropped audio (it doesn’t happen much anyway). By default, a certain amount is allocated to the GPU, since this is headless, we can remove that.

cd /boot
mv start.elf orig-start.elf
cp arm224_start.elf start.elf


Shairport has been updated to support iOS and with it now depends on perl-net-sdp. This can be installed from the AUR using these instructions

83 replies on “AirPi: DIY Airplay Speakers using Shairport and a Raspberry Pi”

Wish I had seen this before I bought a refurb AirPort Express. I guess by the time I bought WiFi for the Pi though I would have been out almost as much.

Great write up!

I see some typos.. “alsa-util” should be “alsa-utils” and “alsa-mixer” should be “alsamixer”.. Other than that, I got a lot of problems. First one is the /etc/rc.conf .. just does not seem to work, have to run the modprob command manualy. And I get errors while trying to run the “./ -a AirPi” command after make. “Can’t locate Net/”. So I tried to run “cpan install Net::SDP”, but get an error “Couldn’t untar Net-SDP-0.07.tar
Package seems to come without Makefile.PL.” Any suggestions…

Thanks, I got it running now. But still have problems with the /etc/rc.conf .. not working. Strange. Great writeup by the way 🙂

Ok. Got it working. Seems like they dont use the /etc/rc.conf anymore.

I ran.
“systemctl enable avahi-daemon”

Then I made a file “/etc/modprobe.d/default.conf”
and added
“services snd-bcm2835” to the file. Reboot. And now works as expected.

Oh.. the last part is wrong.

So. Instead of making the /etc/rc.conf, I ran the command
“systemctl enable avahi-daemon”

Then I made a file /etc/modules-load.d/snd-bcm2835.conf and added the “snd-bcm2835” to it.


Hi Guys,

I can’t seem to get to automatically start when booting up. I first tried the rc.conf ‘method’ which didn’t seem to work. Then I used Stain’s instructions and added daemon.. But i can’t seem to get to automatically start.. Am I doing something wrong?

When i manually start it through an ssh shell it works perfectly..

I know it’s an old post but I hope you guys can help me.



Hi Rik.

I’ve just gone through the process using the current Arch build so I can update this post – a lot has changed. Stain only explained adding Avahi to the boot list for systemd (you should need to bother with the snd-bcm2835 module part now as it auto loads).

With systemd you need to create a shairport.service file in /etc/systemd/system (vi /etc/systemd/system/shairport.service), containing the following:

Description=Startup ShairPort (Apple AirPlay)

ExecStart=/usr/local/bin/shairport -a AirPi -b 256 -d
ExecStop=/usr/bin/killall shairport


Finally, enable the service at startup:

systemctl enable shairport

This should solve your problem.

I’m having the same problem with “Couldn’t untar Net-SDP-0.07.tar”, but I can’t work out how you/he fixed it. How do I install the additional dependency?

You need to follow the steps on the Arch wiki, which explain installing from the AUR. In this case the ‘perl-net-spd’ package

Here’s the link:

The basic steps are:
1. download the package (wget should work [you’ll need pacman -S wget first])
2. extract (tar -zxzf perl-net-sdp.tar.gz)
3. cd perl-net-sdp
4. makepkg
5. pacman -Syu
6. pacman -U perl-net-sdp.pkg.tar.xz

And it should work. Hope that explains what you were after.

hello john! does this works to stream by airpi from iphone to car stereo? is there any possibility to adapt the programing for arduino? please excuse my ignorance. Bye

Yes you could do that with this and a RaspberryPi to make a airplay compatible car stereo. It’s something I considered myself but ending up just building a dock into my dashboard instead. Let me know if you do it.

It wouldn’t be possible with an Arduino, it doesn’t have the processing power. I was going to suggest you could try a bluetooth module and do it that way instead but the digital to analogue converter is too slow for music.

I am using this for my car stereo actually. I have a cheap car stereo with aux in, and USB… so I use the usb to power the Rasp, and the aux for the analog audio.. works like a charm.. I had to add a usb wifi thing, and sett it up as an Access Point. But there are guides for this. Good luck.

Thanks. By tidy integration you mean you cant see the mess behind it 🙂 Integrated mess. Next part is to make a new(old) interface for the stereo itself, make it all look a bit more 1969.

Hello John!
Just started tinkering with Arch/Raspberry Pi, but your instructions got me safely through!
Now I can upgrade my old Marantz-Amp with “Airplay”…
Thank you very much for your write up!

Leave a Reply