MPD / Lighttpd ...wasted 12 hours...hope this help

I wanted to use Dietpi to simply have a lightweight MPD server with cover art. Files on a Nas, Raspberry as a player, Ipad with Irok as a remote.

Pretty straight forward. I thought. But it took me many hours and readings from many different forums to get it running and I thought, lets at least share notes, so that others can save their time…any maybe at some day the dietpi creators even can change some setting so it becomes nearly plug and play.

So…that is what I did:

  • I used the Dietpi config menu to create a mounted NAS drive. That work like a charme, BUT you have to go into /etc/fstab and change the permissions which the Dietpi is setting initially. Other wise lighttpd does not work. There are two settings file_mode and dir_mode and the inital setting will not allow lighttpd to open the mounted directory to fetch the coverart. So I changed it to 0777 both and now we are in business. chmod and chown did not work as it is a mounted drive…many hours to figure that out.

  • I installed MPD and lighttpd from the software menu

  • In lighttpd, change the source to your mount and enable directory listing, so you easily should be able to browse now your mounted directory with the IP of your dietpi player

  • In MPD, # the localhost setting or your mpd server is not known in the network and look carefully on the output setting, it resamples everything to 44k and mane your dac can do more

In theory I guess one could make the inital setting of the mounting permissions, with this the lighttpd settings and finally the Mpd defoult settings in a way that it is install and play…but currently you really need to dig into the conf files much more than I would like.

Hi,

many thanks for your message and sharing your solution.

Well DietPi can not foreseen each and every use case, as there are quite a lot of software title available. So yes, sometimes it’s needed to have some manual steps done.

Regarding the mount point from your NAS. You could have placed the lighttpd user (www-data) into the dietpi user group. This should have enabled lighttpd to access the share. In general dietpi user group is used for cross application access. It’s a more secure way than enabling r/w access for each and everybody on your system :wink:

Not sure if i understood you correctly but

usermod -a -G www-data dietpi

does not have the desired outcome on current DietPi_RPi-ARMv7-Buster_AlloGUI.7z
I did restart lighttpd service but still getting access error.

Update error!

Failed to open directory:
/mnt/audio/

Check media_dir value in the config.inc.php file
Check file permission

Yes, ls /mnt/audio/ shows subfolders

pls can you post output of ls -la /mnt/audio/

Thanks for the reply, got it working now but not sure if i should like full 0777
works with,

//nas/audio /mnt/audio cifs credentials=/root/.smbcreds,iocharset=utf8,sec=ntlmv2,vers=3,file_mode=0777,dir_mode=0777

Going to look into it deeper tomorrow, if it would work also with vers=3.1.1 and i need to grasp a bit of understanding for uid and gid.
Would you say that 0770 as dietpi drive-manager sets, would work with ompd?

Hi,

uid = User who mounts the samba share
gid = User Group who mounts the share

Using drive manager will always have user/group dietpi to mount the drive with 770 permission. Means you would need to add application users to group dietpi.

I guess you mixed it on your command usermod -a -G www-data dietpi because you added user dietpi to group www-data. But it should be the other way around :wink:

usermod -a -G examplegroup exampleusername

means in your case

usermod -a -G dietpi www-data

Intention is to have group dietpi as cross application group to be able to exchange data between different applications. This will be implemented with upcoming release 6.33 https://github.com/MichaIng/DietPi/blob/b02b04e7dc3d1a109c6d1998417e218d7947621a/CHANGELOG.txt#L11

Thanks, i’ll revert and make changes later today.

Curious though why most of the /var/www/ files in 6.32 AlloBoss are all root:root and not www-data.
Would i brake things if i run a chown -R www-data:www-data on the /var/www/ folder?

not sure if there is anything special on the Allo version. Maybe MichaIng knows :slight_smile:

followed your advice, corrected groups and everything works nicely now.

About the /var/www/ folder, this is how it looks after a fresh install.

root@hifi:~# ll /var/www/
total 88K
drwxr-xr-x  4 root     root     4.0K Sep 10 19:46 .
drwxr-xr-x 12 root     root     4.0K Oct  8 09:21 ..
drwxrwx--- 12 www-data www-data 4.0K Mar 31  2020 allo
-rw-r--r--  1 root     root      38K Sep 10 19:16 apc.php
-rw-r--r--  1 root     root      217 Sep 10 19:46 index.php
drwxrwxr-x 18 root     root     4.0K Oct  7 23:12 ompd
-rw-r--r--  1 root     root      23K Sep 10 19:16 opcache.php
-rw-r--r--  1 root     root       20 Sep 10 19:16 phpinfo.php



root@hifi:~# ll /var/www/ompd/                                                                                         
total 1.2M                                                                                                             
drwxrwxr-x 18 root     root     4.0K Oct  7 23:12 .     
drwxr-xr-x  4 root     root     4.0K Sep 10 19:46 ..      
-rw-rw-r--  1 root     root      217 Sep  6 21:09 .gitignore 
drwxrwxr-x  4 root     root     4.0K Sep  6 21:09 PHPsimpleHTMLDomParser
-rw-rw-r--  1 root     root     1.8K Sep  6 21:09 README.md    
-rw-rw-r--  1 root     root      51K Sep  6 21:09 about.php           
-rw-rw-r--  1 root     root      13K Sep  6 21:09 ajax-album-playlist.php
-rw-rw-r--  1 root     root     6.3K Sep  6 21:09 ajax-blacklist.php
-rw-rw-r--  1 root     root     2.2K Sep  6 21:09 ajax-change-player.php
-rw-rw-r--  1 root     root     2.5K Sep  6 21:09 ajax-evaluate-status.php
-rw-rw-r--  1 root     root     6.5K Sep  6 21:09 ajax-favorite-arrange-MPD.php
-rw-rw-r--  1 root     root     5.8K Sep  6 21:09 ajax-favorite-arrange-Tidal.php
-rw-rw-r--  1 root     root      14K Sep  6 21:09 ajax-favorite-arrange.php
-rw-rw-r--  1 root     root     1.9K Sep  6 21:09 ajax-favorite-list.php
-rw-rw-r--  1 root     root     5.6K Sep  6 21:09 ajax-favorite.php
-rw-rw-r--  1 root     root     2.1K Sep  6 21:09 ajax-get-hra-audio-format.php
-rw-rw-r--  1 root     root     2.4K Sep  6 21:09 ajax-hra-search.php
-rw-rw-r--  1 root     root     3.6K Sep  6 21:09 ajax-last-played.php
-rw-rw-r--  1 root     root     7.3K Sep  6 21:09 ajax-playlist-mini.php
-rw-rw-r--  1 root     root     7.5K Sep  6 21:09 ajax-playlist-save.php
-rw-rw-r--  1 root     root     5.2K Sep  6 21:09 ajax-playlist-sync.php
-rw-rw-r--  1 root     root     4.2K Sep  6 21:09 ajax-random-files.php
-rw-rw-r--  1 root     root     2.2K Sep  6 21:09 ajax-suggested.php
-rw-rw-r--  1 root     root     2.2K Sep  6 21:09 ajax-tidal-search.php
-rw-rw-r--  1 root     root     4.1K Sep  6 21:09 ajax-track-version.php
-rw-rw-r--  1 root     root     1.9K Sep  6 21:09 ajax-update-progress.php
-rw-rw-r--  1 root     root     8.3K Sep  6 21:09 ajax-yt-search.php
-rw-rw-r--  1 root     root     2.0K Sep  6 21:09 ajax.php
drwxrwxr-x  4 root     root     4.0K Sep  6 21:09 api
-rw-rw-r--  1 root     root      17K Sep  6 21:09 browser.php
drwxrwxr-x  2 www-data www-data 4.0K Sep  6 21:09 cache
-rw-rw-r--  1 root     root     3.4K Sep  6 21:09 cache.php
drwxrwxr-x 12 root     root     4.0K Sep  6 21:09 codemirror
-rw-rw-r--  1 root     root     5.1K Sep  6 21:09 config-update-select.php
-rw-rw-r--  1 root     root      50K Sep  6 21:09 config.php
-rw-rw-r--  1 root     root     9.4K Sep  6 21:09 cover.php
drwxrwxr-x  2 root     root     4.0K Sep  6 21:09 covers
-rw-rw-r--  1 root     root      40K Sep  6 21:09 download.php
-rw-rw-r--  1 root     root      35K Sep  6 21:09 favorite.php
drwxrwxr-x  6 root     root     4.0K Sep  6 21:09 fonts
-rw-rw-r--  1 root     root      24K Sep  6 21:09 genre.php
drwxrwxr-x  6 root     root     4.0K Sep  6 21:09 getid3
drwxrwxr-x  2 root     root     4.0K Sep  6 21:09 image
-rw-rw-r--  1 root     root      15K Sep  6 21:09 image.php
-rw-rw-r--  1 root     root     1.9K Sep  6 21:09 image_crop.php
drwxrwxr-x  2 root     root     4.0K Oct  8 08:14 include
-rw-rw-r--  1 root     root      63K Sep  6 21:09 index-view2.php
-rw-rw-r--  1 root     root      33K Sep  6 21:09 index-view3.php
-rw-rw-r--  1 root     root      87K Sep  6 21:09 index.php
drwxrwxr-x  2 root     root     4.0K Sep  6 21:09 javascript-src
drwxrwxr-x  2 root     root     4.0K Sep  6 21:09 jquery
-rw-rw-r--  1 root     root     7.9K Sep  6 21:09 json.php
-rw-rw-r--  1 root     root      35K Sep  6 21:09 license.txt
-rw-rw-r--  1 root     root     3.9K Sep  6 21:09 login.php
-rw-rw-r--  1 root     root      130 Sep  6 21:09 manifest.json
-rw-rw-r--  1 root     root      325 Sep  6 21:09 manifest.webmanifest
-rw-rw-r--  1 root     root     4.7K Sep  6 21:09 message.php
-rw-rw-r--  1 root     root      640 Sep  6 21:09 offline.html
-rw-rw-r--  1 root     root     9.2K Sep  6 21:09 opensearch.php
-rw-rw-r--  1 root     root     2.3K Sep  6 21:09 phpinfo.php
-rw-rw-r--  1 root     root      81K Sep  6 21:09 play.php
-rw-rw-r--  1 root     root      14K Sep  6 21:09 playlist-mini.php
-rw-rw-r--  1 root     root      52K Sep  6 21:09 playlist.php
-rw-rw-r--  1 root     root      15K Sep  6 21:09 playlistDel.php
-rw-rw-r--  1 root     root     7.9K Sep  6 21:09 record.php
-rw-rw-r--  1 root     root     6.4K Sep  6 21:09 ridirect.php
-rw-rw-r--  1 root     root      55K Sep  6 21:09 search.php
-rw-rw-r--  1 root     root     3.1K Sep  6 21:09 service-worker.js
drwxrwxr-x  8 root     root     4.0K Sep  6 21:09 skin
drwxrwxr-x  2 root     root     4.0K Sep  6 21:09 sql
-rw-rw-r--  1 root     root      38K Sep  6 21:09 statistics.php
drwxrwxr-x  2 www-data www-data 4.0K Sep  6 21:09 stream
-rw-rw-r--  1 root     root      30K Sep  6 21:09 stream.php
drwxrwxr-x  2 www-data www-data 4.0K Oct  7 23:16 tmp
drwxrwxr-x  2 root     root     4.0K Sep  6 21:09 tools
-rw-rw-r--  1 root     root      84K Sep  6 21:09 update.php
-rw-rw-r--  1 root     root      39K Sep  6 21:09 users.php

Ok good that it is fixed for you now.

Regrading Allo, I need to say, I’m not an expert as I don’t use it. There we need MichaIng as developer.

Jep, usermod -aG dietpi www-data would be also my solution. This is btw not new to v6.33 but only the way a few services run as this group has been changed a bid.

I’m no big fan of adding too much users by default to that group which would break the security aspect. dietpi group is already quite mighty as it gains write access to nearly all userdata in /mnt/dietpi_userdata. Instead we might want to write a documentation page about UNIX permissions in general and how to check/debug/change users and file permissions, as well for special cases (samba mount, FAT file system and such?): https://dietpi.com/docs/
I thinks this would be very useful and simply an important topic when running a UNIX server in general :slight_smile:.

Regarding Allo and /var/www in general. In the past indeed everything in /var/www was owned by www-data user, but actually that is neither required not recommended (from security perspective). Usually www-data only needs to read the website and to write to it. Only in certain cases where config files are written to via PHP backend or the web application has an internal updater, this is needed. So most /var/www subfolders are root:root owned, so is Allo web UI.