About this HOWTO
This HOWTO provides information required to set up an MP3 streaming unit using Linux and the Music Player Daemon. It also covers interfacing methods through phpMp. This HOWTO is based on personal experiences and is focused around setting up a machine to run without a monitor, keyboard or mouse and be controlled by either SSH, or through a web-browser such as Internet Explorer, or Pocket Internet Explorer on my iPaq PDA.
A Quick Summary…
To get everything working, we will need to complete the following tasks:
Download libraries, MPD, phpMp
Install external libraries for MPD
Install Music Player Daemon
Configure Samba to access a Windows file share containing the MP3's
Mount the share
Configure Apache, mod_php and phpMp
Start MPD
Test it!
Getting Started
Before you start installing MPD or any of the required libraries, it's necessary to have a working Linux platform. My personal preference is Slackware, so my box was set up with Slackware 9.1. Instead of bothering with upgrading to the latest kernel, I decided to leave my machine running with the default kernel which in this case is 2.4.22. However, you might find it necessary to upgrade to a later version such as 2.6.6 [current] for hardware support or suchlike. In my case, I am lucky to have a machine that is fully supported sound-wise under 2.4.22, with a C-Media 8738-based onboard sound system.
Hardware
The machine that I am setting up MPD on is by no means powerful - but is still in excess for the task. MPD is known to have been run on a machine as low as a Pentium 75. My setup consists of:
AMD K6-2 400MHz
160Mb PC100 RAM
SiS 530 Based Motherboard
Onboard VGA
Onboard C-Media 8738 Sound
Compaq 8x CD-ROM Drive
Maxtor 4Gb Hard Drive
Realtek 8139-based NIC
Stage 1: Downloading libraries, MPD, phpMp
Obtain the archives from the sites. My method would be to create an input file for 'wget' and download everything at the same time.
cd / && mkdir downloads && cd downloads && pico list
Populate the input file with the URLs for the archives.
http://www.zlib.net/zlib-1.2.1.tar.gz
http://opensys.linuxpackages.net/Slackware-9.1/jay/libao/libao-0.8.5-i686-1jto.tgz
http://mercury.chem.pitt.edu/~shank/mpd-0.10.4.tar.gz
http://mercury.chem.pitt.edu/~shank/phpMp-0.10.2.tar.gz
Then use the -i switch to download the files into your downloads directory.
wget -i list
Note- the libao package is from an external site, and is pre-compiled. I used this as xiph.org was down whilst writing this HOWTO :
Stage 2: Installing the external libraries.
Starting with libao, making sure you're in /downloads…
installpkg libao-0.8.5-i686-1jto.tgz
And moving on to zlib… As zlib is a .tar.gz archive, extract it first..
tar -zxvf zlib-1.2.1.tar.gz
Then enter the directory, configure the compiler, make and install! Then it will cd out of the directory and back into /downloads, ready for the next stage.
cd zlib-1.2.1.tar.gz && ./configure && make && make install & cd /downloads
Stage 3: Installing MPD…
Again, MPD is provided in a .tar.gz archive ready for us to compile it ourselves. First, extract it..
tar -zxvf mpd-0.10.4.tar.gz
Change into the mpd directory, and configure the compiler.
cd mpd-0.10.4.tar.gz && ./configure
At this point, you'll be warned if any of the libraries haven't installed properly. If you've followed the instructions properly though, you should be fine and told that you can now compile MPD with make.
make
Finally, install MPD.
make install
Stage 4 & 5: Configuring Samba to access the Windows share containing the MP3's
Mounting the share within Linux
In my setup, I hold all my MP3 files externally on my main machine running Windows XP. Because of this, Samba needs to be configured to read the MP3 files from a Window share. To tidy things up a bit, a mount point will be created allowing Linux to refer to the share via a simpler location.
Lets start by adding the mount point in to /etc/fstab. Fstab is the file that defines where all the mountpoints lead to.
pico /etc/fstab
Add in a line to the bottom of the fstab like so:
\\192.168.0.2\MP3 /media smbfs credentials=/etc/samba/media.auth 0 0
(Where \\192.168.0.2\MP3 is the Windows share.)
Write out the file by pressing CTRL+O. Now create the media.auth file using Pico…
pico /etc/samba/media.auth
In media.auth, define the configuration for the setup.
username = windows_username
domain = WORKGROUP
password = windows_password
Replace windows_username, WORKGROUP and windows_password with the appropriate strings. Again, write out the file with CTRL+O.
Now create the directory for the mount to be assigned to.
mkdir /media
And finally, mount the share.
mount /media
Test the share by cd'ing into it, and then performing an ls.
cd /media
ls
Stage 6: Configure Apache, mod_php and phpMp
This section is assuming that Apache has been installed and is started automatically at startup, however has never been used.
We start by making some changes to the httpd.conf file.
pico /etc/apache/httpd.conf
Press CTRL+W and type
DirectoryIndex
And press enter. This is searching httpd.conf for the string DirectoryIndex. It should take you to a section with a commented introduction to the DirectoryIndex system. Modify the part below like so:
<IfModule mod_dir.c>
DirectoryIndex index.php index.html
</IfModule>
Then, use PageDn to scroll to the bottom of httpd.conf, then move up a bit and un-comment the line
Include /etc/apache/mod_php.conf
Write out the file (CTRL+O) and restart Apache with
apachectl restart
Now we will extract phpMp and install it.
cd /downloads
tar -zxvf phpMp-0.10.2.tar.gz
mv phpMp-0.10.2 /var/www/htdocs/phpMp
Now you can access phpMp from
http://serverip/phpMp/
If you need to, you can edit the phpMp configuration by using:
pico /var/www/htdocs/phpMp/config.php
However I will use the default configuration.
Stage 7: Starting MPD
First create some directories and files for MPD to use as error and log files. These can be helpful when trying to diagnose whats wrong if MPD fails. I decided to create the two files in /home/mpd just so I knew where they were. I'm not too sure whether you actually need to do this.
Mkdir /home/mpd
Pico /home/mpd/mpd.log
CTRL + O
Pico /home/mpd/mpd.error
CTRL + O
Then start MPD for the first time with the full command:
mpd 2100 /media /media /home/mpd/mpd.log /home/mpd/mpd.error
This will create a database from your /media directory. You should see all the files flash past.
Now simply run MPD.
mpd
Access MPD through phpMp by opening
http://serverip/phpMp/ in a web-browser.
Also, I created an entry in /etc/rc.d/rc.local to start mpd at boot time.
pico /etc/rc.d/rc.local
And add the line:
/usr/local/bin/mpd
Write out using CTRL+O, reboot, and you're done!