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

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
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
Please forgive my ignorance DCR? I am not familiar with that. Is that for playing something other than music?
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
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
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
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
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/
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...
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.
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. 😃
Userlevel 2
Very handy! Better bookmark this for later 😉
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.
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!