Music Player Daemon for streaming music on your website

On Debian server

You can configure this even on your headless remote server as this does not require sound card. Only terminal connection to your server is needed.

Install mpd music player daemon

apt install mpd

Edit /etc/mpd.conf

Comment out and add your server address

bind_to_address "Your.server.IP.address"

You could uncomment change port to control mpd daemon and change

port "6600"

Uncomment

auto_update "yes"

Uncomment and setup your password for daemon when connecting with client. You can configure access level using read,add,control,admin.

password "yourpassword@read,add,control"

Comment

#audio_output {
#type "alsa"
#name "My ALSA Device"

Uncomment

audio_output {
type "httpd"
name "My HTTP Stream"
encoder "vorbis" # optional, vorbis or lame
port "8000"
bind_to_address "0.0.0.0" # optional, IPv4 or IPv6
# quality "5.0" # do not define if bitrate is defined
bitrate "96" # do not define if quality is defined
format "44100:16:2"
max_clients "0" # optional 0=no limit
}

To make configuration available you need to restart mpd daemon.

sudo service mpd restart

 

Install mpc client

sudo apt install mpc

You can configure password and port for client connection using environment variables.

export MPD_HOST=yourpassword@localhost

export MPD_PORT=6600

Create symbolic link to your own music folder where permissions should allow other users at least read files.

ln -s /home/user/music /var/lib/mpd/music/

Go to mpd music folder/var/lib/mpd/music/ and add all files to default mpd playlist

mpc ls | mpc add

Check if files are on playlist using mpc playlist and play using mpc play.

There is also very nice and practical ncurses based CLI app named ncmpcpp

sudo apt install ncmpcpp

Read more about ncmpcpp

You can now enter to your server website via web browser typingYour.server.IP.address:8000

If everything is ok, you’ll hear now music and your music stream is all setup.

Read more about mpd