Install Shairport on Raspberry Pi

Posted by Max Power | Posted in Android, Raspberry Pi | Posted on 04-11-2014-05-2008


This post will walk the user through the process of installing Shairport on the Raspberry Pi.  The following instructions assume that you are using the standard Raspbian (Debian Wheezy) install, it is installed and running, and you are connected to the internet.

Once you have Shairport installed and running, you will be able to stream audio from your Apple or Android device to the Raspberry Pi.  AllStream Cast+AirPlay+DLNA and AirPlay DLNA SONOS Chrome Roku are two applications for Android that will allow you to stream audio from you device to an AirPlay device or multiple devices.  Sonos replacement????

Update Packages

First make sure that your packages are up to date
sudo apt-get update && sudo apt-get upgrade

Install Prerequisites

Install the prerequisite packages
sudo apt-get install build-essential libssl-dev libcrypt-openssl-rsa-perl libao-dev libio-socket-inet6-perl libwww-perl avahi-utils pkg-config git libssl-dev libavahi-client-dev libasound2-dev libpulse-dev libmodule-build-perl

sudo apt-get install chkconfig

Update Firmware

Make sure that your firmware is up to date, this will hopefully avoid the popping noise when the audio is selected
sudo git clone git://
sudo rpi-update/rpi-update

Reboot to activate the new firmware
sudo reboot

Install Perl Net-SDP

Apparently a change in IOS 6 requires this module to be installed or else shairport will crash.
sudo git clone perl-net-sdp
cd perl-net-sdp
sudo perl Build.PL
sudo ./Build
sudo ./Build test
sudo ./Build install
cd ..


To avoid the error “Unknown PCM cards.pcm.front”, modify the ALSA config (refrence:
sudo nano /usr/share/alsa/alsa.conf
Change the line “pcm.front cards.pcm.front” to “pcm.front cards.pcm.default”


Now we will modify the avahi-daemon init.d script to fix the issue with avahi-daemon that gives the “avahi-daemon disabled because there is a .local domain” on many networks.
sudo nano /etc/init.d/avahi-daemon
Modify the line DISABLE_TAG=”/var/run/avahi-daemon/disabled-for-unicast-local and change it to DISABLE_TAG=”/var/run/avahi-daemon/disabled-for-unicast-local-DISABLE
Restart the avahi-daemon
sudo service avahi-daemon restart


Install Shairport
sudo git clone -b 1.0-dev git://
cd shairport
sudo ./configure
sudo make
sudo make install

Start Shairport and test it to see if it is working
./shairport -a 'AirPlay'
Now using one of the Andriod apps listed above or iTunes you should be able to see this device and stream music to it. If you have speakers connected to the 3.5mm jack you may have to make that the default output for audio (see the audio setup below).

We are done in this folder
cd ..

Audio Setup

The following command will set the output to the 3.5mm jack (by default it is set to the HDMI)
sudo amixer cset numid=3 1
Adjust the audio level with the following command
*Note: If you get one of these errors: ‘amixer: Control default open error: No such file or directory’ or ‘cannot open mixer: No such file or directory’, the following command should fix things (Ref)
sudo modprobe snd_bcm2835

Starting Shairport on boot

Next we will set Shairport to launch on boot, first we will copy the startup script
sudo cp scripts/debian/init.d/shairport /etc/init.d/shairport

I want the start up script to use the pi user and not the admin user as it is setup to by default, therefore I need to edit the start up script
sudo nano /etc/init.d/shairport
Edit the following lines to read (reference:
Note: The name of the device is set by default to the name of the Raspberry Pi. If you don’t want that, you can change AP_NAME and give it the name you want.

cd /etc/init.d
sudo chmod a+x shairport
sudo update-rc.d shairport defaults

Shairport Watchdog

We want to make sure that avahi-daemon starts before shairport otherwise shairport will fail.  The script will use pgrep so we need to install those packges
sudo apt-get install pcregrep pgrep
Now we will write a script called in /root
sudo nano /root/
that contains the following code (reference:
# find service pids
pgrep shairport
#if we get no pids, service is not running
if [ $? -ne 0 ]
service shairport start
echo "shairport started or restarted."

Now edit the /etc/crontab file
sudo nano /etc/crontab
and add the following line
* * * * * root /bin/sh /root/ > /dev/null
Final cleanup
sudo chown -R pi:pi /home/pi/