Sonos with Linux detailed Howto


Sonos without Windows
I have a Linux server running Debian, a close relation of Ubuntu and a laptop running Ubuntu. I bought a Sonos ZP90 but not the controller. I found various bits and pieces on the internet on how to get this working but no complete howto so I thought it would be useful to others if I created a detailed guide for Google to find :-)

Physical set-up
The Sonos and server are connected to my ADSL modem with ethernet cables. The laptop connects via wireless.

Sharing the music
On the server create a new users sonos
code:
sudo adduser sonos
sudo passwd sonos

and enter a new password.
Check that user sonos can read your music files
code:
su - sonos
cd
ls
cd
ls
exit

check you have Samba installed
code:
dpkg --get-selections | grep samba

If you have it returns
code:
samba-common                                   install

If not install it with
code:
sudo apt-get install samba

Back up the config
code:
sudo mv /etc/samba/smb.conf /etc/samba/smb.conf.orig

then create /etc/samba/smb.conf to look like this
code:
[global]
workgroup = server
netbios name = server
server string = Samba Server %v
load printers = no
log file = /var/log/samba/log.%m
max log size = 50
socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192
interfaces = lo eth0
security = user
password level = 12
username level = 12
encrypt passwords = yes
username map = /etc/samba/smbusers

[musicshare]
path =
valid users = sonos
read only = yes
printable = no
only guest = no

and create a samba users file /etc/samba/smbusers
to look like this
code:
root = administrator admin
nobody = guest pcguest smbguest
sonos = sonos


This next is a new feature for Samba that some of the older howto's didn't need:
code:
sudo smbpasswd -a sonos

and enter a password. This is the one you will use below during the Sonos set-up.

Restart samba to use the new config
code:
sudo /etc/init.d/samba restart


Check it's working
code:
sudo vi /var/log/samba/log.?mbd


Tell Sonos about the music

On the laptop, install Wine
code:
sudo apt-get install wine


Insert the Sonos installation CD, open it with file browser. Right click on setup.exe and choose "open with Wine Windows Program Loader". Follow the usual install instructions. (If the application can't find your Sonos device then try connecting the laptop to your network using an ethernet cable and turn off your wireless connection. This is only necessary for the initial discovery steps.) On the "select music source" page choose "add music stored in folders that are currently shared on my network".
  1. Path: \\server\musicshare (replace "server" with the hostname of your server)
  2. User name: sonos
  3. Password: whatever you typed at the smbpasswd command above

and you should be in business. If not you might get some useful debug from the error message that Sonos gives you.

Web interface

At this point you should be able to play music using the Sonos controller on the laptop running under Wine. However if you have multiple users on your laptop you will have to install it for each of them. For this reason or just because you prefer a web interface you can install the lovely software Sonos web controller.

On the server
code:
wget http://www.purple.org/sonos/sonosweb-0.72.tar.gz

(check that there hasn't been a new release)
code:
tar -xzf sonosweb-0.72.tar.gz
cd sonos
./sonos.pl -config

I you get an error about
code:
Can't locate SOAP/Lite.pm in @INC

then you need to
code:
sudo perl -MCPAN -e "install Data::Dumper"
sudo perl -MCPAN -e "install SOAP::Lite"
sudo perl -MCPAN -e "install LWP::UserAgent"
sudo perl -MCPAN -e "install HTTP::Daemon"
sudo perl -MCPAN -e "install XML::Simple"
sudo perl -MCPAN -e "install HTML::Template"l

which takes a while. Ignore any errors you might get.
For sonos config select the defaults apart from "location on local disk that Sonos indexes" which you should change to point to where you have your music. Install the software
code:
sudo mv sonos /usr/local/share


And now prepare to run it in the background
code:
screen
cd /usr/local/share/sonos
./sonos.pl


If it starts happily then you can do "ctrl-a d" (ie press control and the "a" button at the same time then just the "d" button) to detach from the session and leave it running. To come back to it use
code:
screen -r


On the laptop you should now be able to point a browser at http://server:8001 and away you go!

Good luck,
Dougal

This topic has been closed for further comments. You can use the search bar to find a similar topic, or create a new one by clicking Create Topic at the top of the page.

50 replies

Thanks, I just spent the best part of 4 hours trying to link my Sonos to my debian server, Windows was no problem.
ntlm auth = yes
is the right answer!
Just in case anyone comes across this post: Since Samba 4.X.X you might need to add

ntlm auth = yes

in the global block of your smb.conf to enable your System to connect to your Samba share.
Userlevel 2
Very handy! Better bookmark this for later 😉
Userlevel 2
... today I decided to try to install Sonos Android app to my Chromium browser using Arc Welder and it works perfectly! You may also want to consider this option.

You made my day - thank you !!!

Tried this method weeks ago on a chromebook, but there the app didn't find my SONOS-system 😞 (I think there are issues with working on devices at the local network, i.e. on a chromebook you also can't address your printer at local network directly).

BUT: After reading this post I tried it again in Chrome-browser on Linux Mint and what a surprise: it works perfectly as you told. 😃
Has anyone had any luck getting the latest sonos 5.x players running in linux? I've been trying for a couple days no wtih no success and am now on the hunt for the older 4.x vs to see if any of them will still run...
Hello, 5.3 will install when using the latest wine-staging with dotnet40 installed through winetricks. However, the Sonos app is then still unable to play anything from Deezer.

This is really painful, so today I decided to try to install Sonos Android app to my Chromium browser using Arc Welder and it works perfectly! You may also want to consider this option.
Has anyone had any luck getting the latest sonos 5.x players running in linux? I've been trying for a couple days no wtih no success and am now on the hunt for the older 4.x vs to see if any of them will still run...
Userlevel 2
All I did was get a new sonos.pl from this archive

https://github.com/miracle2k/sonosweb/archive/master.zip

and replaced the sonos.pl from the purple.org version with all of the other code the same.

If I had to do it again I would just install the whole package from here : https://github.com/miracle2k/sonosweb/
Userlevel 2
I don t know much about scripting but what i know is that i download a free app working on android devices to control amarok...
Maybe is it possible to script something that ask amarok not to play file but to ask samba to send file ? **** i bet it s not this way ... amarok could ask sonos to ask samba ? ahhh.... i thought i had an issue, just adding ideas so .... sorry
Userlevel 2
I read all of the posts on Sonosweb, made the changes to sonos.pl, and installed the CPAN modules (rather than the Debian packages for them). I'm running Debian Wheezy and I can see the pages for the webserver but none identify zones.

Here is the startup

./sonos.pl
4/224318 crit: ./sonos.pl:172 main::main Starting up version 0.72!
If the application doesn't seem to work:
* you may need to disable your firewall or allow the application
* make sure the computer is on the same network as Sonos boxes
* make sure the Sonos Controller software isn't running on the same computer

Now, point your browser to http://localhost:8001 and leave this running

4/224318 alert: ./sonos.pl:561 main::sonos_prefsdb_load Loading Prefs DB
4/224318 info: ./sonos.pl:571 main::sonos_renew_subscriptions invoked
4/224318 alert: ./sonos.pl:244 main::plugin_load Loading Plugins
4/224318 notice: ./sonos.pl:1273 main::upnp_search_cb Added name: 192.168.1.10 - Sonos CONNECT:AMP uuid:RINCON_000E5.... type: urn:schemas-upnp-org:device:ZonePlayer:1
4/224319 notice: ./sonos.pl:1273 main::upnp_search_cb Added name: 192.168.1.7 - Sonos BRIDGE uuid:RINCON_000E..... type: urn:schemas-upnp-org:device:ZonePlayer:1
4/224319 notice: ./sonos.pl:1273 main::upnp_search_cb Added name: 192.168.1.8 - Sonos PLAY:5 uuid:RINCON_000E..... type: urn:schemas-upnp-org:device:ZonePlayer:1

When I browse to the Sonosweb pages, there is just an endless loop as it searches for zones without success

4/224741 alert: ./sonos.pl:1407 main::http_handle_request URI: /index.html
4/224741 info: ./sonos.pl:2126 main::http_send_response Sending response to /index.html
4/224741 alert: ./sonos.pl:1407 main::http_handle_request URI: /favicon.ico
4/224741 alert: ./sonos.pl:1407 main::http_handle_request URI: /favicon.ico
4/224746 alert: ./sonos.pl:1407 main::http_handle_request URI: /isonos/index.html
4/224746 info: ./sonos.pl:2126 main::http_send_response Sending response to /isonos/index.html
4/224746 alert: ./sonos.pl:1407 main::http_handle_request URI: /isonos/inc/prototype.js
4/224746 alert: ./sonos.pl:1407 main::http_handle_request URI: /isonos/inc/scriptaculous.js
4/224746 alert: ./sonos.pl:1407 main::http_handle_request URI: /isonos/inc/iSonos.js
4/224746 alert: ./sonos.pl:1407 main::http_handle_request URI: /isonos/inc/noartwork.png
4/224746 alert: ./sonos.pl:1407 main::http_handle_request URI: /isonos/inc/main.css
4/224746 alert: ./sonos.pl:1407 main::http_handle_request URI: /isonos/inc/builder.js
4/224746 alert: ./sonos.pl:1407 main::http_handle_request URI: /isonos/inc/effects.js
4/224746 alert: ./sonos.pl:1407 main::http_handle_request URI: /isonos/inc/dragdrop.js
4/224746 alert: ./sonos.pl:1407 main::http_handle_request URI: /isonos/inc/controls.js
4/224746 alert: ./sonos.pl:1407 main::http_handle_request URI: /isonos/inc/slider.js
4/224746 alert: ./sonos.pl:1407 main::http_handle_request URI: /isonos/plugins.html
4/224746 info: ./sonos.pl:2126 main::http_send_response Sending response to /isonos/plugins.html
4/224746 alert: ./sonos.pl:1407 main::http_handle_request URI: /isonos/inc/controlerBG.png
4/224746 alert: ./sonos.pl:1407 main::http_handle_request URI: /isonos/inc/controlerBtn.png
4/224746 alert: ./sonos.pl:1407 main::http_handle_request URI: /isonos/inc/volume.png
4/224746 alert: ./sonos.pl:1407 main::http_handle_request URI: /isonos/inc/search.png
4/224746 alert: ./sonos.pl:1407 main::http_handle_request URI: /isonos/inc/fauxTbl.png
4/224746 alert: ./sonos.pl:1407 main::http_handle_request URI: /isonos/inc/spinner.gif
4/224746 alert: ./sonos.pl:1407 main::http_handle_request URI: /isonos/inc/queueBtn.png
4/224746 alert: ./sonos.pl:1407 main::http_handle_request URI: /isonos/inc/infoLbl.png
4/224746 alert: ./sonos.pl:1407 main::http_handle_request URI: /isonos/inc/sonosbg.jpg
4/224746 alert: ./sonos.pl:1407 main::http_handle_request URI: /isonos/inc/optBtn.png
4/224746 alert: ./sonos.pl:1407 main::http_handle_request URI: /isonos/data/init.json
4/224746 info: ./sonos.pl:2126 main::http_send_response Sending response to /isonos/data/init.json
4/224749 alert: ./sonos.pl:1407 main::http_handle_request URI: /isonos/data/init.json
4/224749 info: ./sonos.pl:2126 main::http_send_response Sending response to /isonos/data/init.json
4/224752 alert: ./sonos.pl:1407 main::http_handle_request URI: /isonos/data/init.json
4/224752 info: ./sonos.pl:2126 main::http_send_response Sending response to /isonos/data/init.json
4/224755 alert: ./sonos.pl:1407 main::http_handle_request URI: /isonos/data/init.json
4/224755 info: ./sonos.pl:2126 main::http_send_response Sending response to /isonos/data/init.json
4/224758 alert: ./sonos.pl:1407 main::http_handle_request URI: /isonos/data/init.json
4/224758 info: ./sonos.pl:2126 main::http_send_response Sending response to /isonos/data/init.json
4/224801 alert: ./sonos.pl:1407 main::http_handle_request URI: /isonos/data/init.json
4/224801 info: ./sonos.pl:2126 main::http_send_response Sending response to /isonos/data/init.json
4/224804 alert: ./sonos.pl:1407 main::http_handle_request URI: /isonos/data/init.json
4/224804 info: ./sonos.pl:2126 main::http_send_response Sending response to /isonos/data/init.json

Any suggestions on how to troubleshoot?
Userlevel 2
Ah well that makes sense. Sorry, I was confused. I just got my Sonos yesterday, and I didn't even know you could control it from anything but an Android. My G/F bought it for a birthday present because I just got a new phone. I just was having an issue getting to my samba shares, googled, and found this thread. Thanks for clarifying. I probably should have started a new thread. My post will get you to your samba shares using the Android controller. I hope it is helpful to some people.
Userlevel 2
Please forgive my ignorance DCR? I am not familiar with that. Is that for playing something other than music?

The DCR is the common abbreviation for the Windows desktop controller.
Userlevel 2
Please forgive my ignorance DCR? I am not familiar with that. Is that for playing something other than music?
Userlevel 2
Can somebody tell me why we need WINE? I mean if we have a Linux server running samba, can't Sonos browse smb

WINE is needed to run the DCR on Linux, not for anything related to file-serving.
Userlevel 2
Can somebody tell me why we need WINE? I mean if we have a Linux server running samba, can't Sonos browse smb? Is there a different way to get the sonos to browse the smb share? Is the wine only to browse over the web? is there a way to get Sonos to browse the local network using just samba?

My phone can mount it smb and or nfs, is there a way to mount the share with the phone then have sonos browse locally to the phone?

I am going to try it.

By the way my NAS is Ubuntu 12.04 server LTS.
Userlevel 2
It's look like to be 1.5.25-0ubuntu1

I use
http://www.ubuntuupdates.org/ppa/wine?dist=precise

After one day, there's some not working tool like adding a samba directory, but as I've also an android phone I can avoid this problem.

It just need a restart after installing dotnet40
Userlevel 2
Hello,

I try this evening install wine1.5 on ubuntu
and add dotnet support
code:
sudo add-apt-repository ppa:ubuntu-wine/ppa
sudo apt-get update
sudo apt-get install wine1.5
winetricks dotnet40


and client controller 4.0 work fine, with some crash, but it's working enough to use it


That's interesting to know.

Which version of WINE are you running? I'm using 1.5.3 here.

I tried this quite some time ago, when the new-look DCR was still in beta. I might have tried again after it was released, but I haven't tried again recently.

When I tried this, I installed .net on my own (i.e. without winetricks) and then the DCR, but it crashed on start.

The DCR has certainly undergone minor changes since then, but I'm wondering whether you're using a newer WINE, too.

The new-look DCR is still classed as garbage on WINE's site, so you might want to update that entry.
Userlevel 2
Hello,

I try this evening install wine1.5 on ubuntu
and add dotnet support
code:
sudo add-apt-repository ppa:ubuntu-wine/ppa
sudo apt-get update
sudo apt-get install wine1.5
winetricks dotnet40


and client controller 4.0 work fine, with some crash, but it's working enough to use it
Userlevel 2
Hello All,

Not sure if anyone is still looking to get the controller working in Linux, but I was able to get it going by using PlayOnLinux to create a virtual drive.


I see that PlayOnLinux uses WINE, but what does PlayOnLinux add to the mix? I can't tell from the project's site what it actually does.

All of which makes me wonder whether it is, perhaps, merely the newest and latest version of WINE that enables the new breed of DCR to work on Linux. Have you tried the DCR under vanilla WINE 1.5.24?
Hello All,

Not sure if anyone is still looking to get the controller working in Linux, but I was able to get it going by using PlayOnLinux to create a virtual drive. The rough instructions are as follows.

1. Download PlayOnLinux from http://www.playonlinux.com/en/
2. Click on Install
3. At the bottom click on the area to install non listed applications.
4. Install a program in a new virtual drive.
5. Name your virtual drive "Sonos" or whatever you would like.
6. Click on use another version of wine, configure wine, and install some libraries.
7. Click on the newest version of Wine you have listed. The working version for me is 1.5.24.
8. When the next window opens change the Windows version to Windows 8 and then click apply then ok.
9. On the next window select POL_Install_dotnet40
(You may see a crash after this step, just click next and continue, the dot net framework should continue to install)
10. After a bit that should complete and you will be prompted to select a program to run. Select the sonos installer and procede as normal.

That should be it, the program should install just fine. The first thing I notice is the fonts don't look all to great, but messing with any of the font settings so far seem to crash the application. Let me know if anyone has any different results. Hopefully this helps someone else. Please ignore any typos or errors in grammar. I just quickly jotted this down as I went through the process.
Userlevel 2
Since version 3.7, it seems that the Sonos Desktop Controller is relying on a new version of the .NET framework (the errors i get seems to state this reason, i am no pro), and this has caused it to not work under Wine no more :(


This may be of some use to you guys.
Userlevel 2
i'm a bit of a wine noob, so didn't really put much effort into fixing this :

knic@crow-t:~/Downloads$ wine SonosDesktopController38.exe
fixme:storage:create_storagefile Storage share mode not implemented.
fixme:storage:create_storagefile Storage share mode not implemented.
wine: Install Mono 2.8 or greater for Windows to run .NET 4.0 applications.
err:msi:ITERATE_Actions Execution halted, action L"InstallFinalize" returned 1627
err:msi:ITERATE_Actions Execution halted, action L"ExecuteAction" returned 1627

Mono is installed on my machine (2.10)


then for the Purple controller:

(after making the havk in the post by skippythelizard.)

Can't call method "subscribe" on an undefined value at ./sonos.pl line 1287.
Userlevel 2
Thanks for the link. However, this does not seem to work with 3.7 :-(

Since version 3.7, it seems that the Sonos Desktop Controller is relying on a new version of the .NET framework (the errors i get seems to state this reason, i am no pro), and this has caused it to not work under Wine no more :(

I hope the Wine developers will see fit to attempt to fix this in the near future, but the effort they are doing to support as much as they do, must not be underestimated! they amount of work they put into developing this awesome piece of software is incredible!
Userlevel 2
Thanks for the link. However, this does not seem to work with 3.7 😞
Badge +4
After updating to Sonos 3.6, the Purple controller no longer sees any of my zones.

I did a little research ...

The problem seems to be that Sonos no longer uses the URL /xml/zone_player.xml in its UPNP implementation. (Also apparently previously, bridges used /xml/zone_bridge.xml, and this controller used the URL to determine whether or not a device was a zone player.)

Sonos now uses /xml/device_description.xml for both players and bridges.

You can get the Purple controller working by editing sonos.pl, and in the search_cb routine, remove this line:

next if ($device->{LOCATION} !~ /xml\/zone_player.xml/);

Replace with these two lines:

next if ($device->friendlyName !~ /Sonos/);
next if (!($device->friendlyName !~ /Sonos BRIDGE/));

If you are on Windows using the compiled version (.exe), this won't work until somebody updates it. You need to run sonos.pl under perl.exe until this happens.

Here are some quick tips for getting Perl setup on Windows for running this controller.

Download the 32-bit/x86 version of Perl (some support libraries used are not currently available in the Windows 64-bit build).

Issue the following commands to download/setup pre-requisite libraries:

ppm install MinGW
perl -MCPAN -e "install SOAP::Lite"


perl sonos.pl is the command to start the controller.
Userlevel 2
Just to let others know, I had a similar problem to that described above with Virtual Box, only in my case with VMWare player. By disabling the VMWare networks, I was able to get the Sonos Desktop Controller to connect with the Sonos Player.

Thanks for the tips that pointed me in the right direction.