Apache (http) MP3 Music Server



Apache mp3 streaming server HOWTO

How to setup an mp3 server using Linux and apache http server.

This HowTO assumes you have a working Apache 2.0 web server with mod_perl (v2) installed.

The following packages are required:

1) mod_perl (version 2 or higher v1.99 doesn't work!)
2) Apache::MP3
3) perl-BSD-Resource
4) root access to the server you're installing on

Locate a mod_perl (version 2 or higher) RPM - a good place to look
is on RPM Find - http://www.rpmfind.net/

Either locate a source RPM and build it yourself, or if available,
download an RPM suitable for your system.
See Here for instructions on building src RPMs.
Once you have mod_perl installed, you need to update the Apache perl
modules.

As root, enter the CPAN shell as follows: >perl -MCPAN -e shell
Then install Bundle::Apache2 as follows:

cpan> install BSD::Resource # Not sure if this is required but can't hurt
cpan> install Locale::Maketext
cpan> install MP3::Icecast
cpan> install MP3::Info
cpan> install MPEG::MP3Info
cpan> install CGI::Session
cpan> install Audio::Wav # if you want to stream wavs (unlikely)
cpan> install Apache::MP3
cpan> install Bundle::Apache2

type quit to exit.

NOTE: I also had to install MPEG::MP3Info as some ID tags were not displaying correctly
Copy the Apache::MP3 images and icon files to apache_mp3 under
your web root.
These files can be found in /root/.cpan/build/Apache
Then add the following entries to /etc/httpd/conf.d/access.conf
You will most likely have to create these two files.

####################################################

Then add the following to /etc/httpd/conf.d/srm.conf
These could also go into httpd.conf, but I prefer to
keep them seperate. You could also add them in a <VirtualHost>
container, which will keep them seperate from any
other hosts on your server.

# httpd.conf or access.conf
<Location /mp3>
SetHandler perl-script
PerlHandler Apache::MP3::Sorted
PerlSetVar CacheDir /path_to_your_tmp_dir/mp3tmp
PerlSetVar AllowDownload no
PerlSetVar DescriptionFormat "[%a] %t (%y)"
PerlSetVar ReadMP3Info yes
PerlSetVar CheckStreamClient yes
</Location>

Note: the CacheDir * must * be outside of your web structure.
e.g. you could place it in /tmp/mp3tmp

####################################################

Then add the following to /etc/httpd/conf.d/srm.conf
These could also go into httpd.conf, but I prefer to
keep them seperate. You could also add them in a <VirtualHost>
container, which will keep them seperate from any
other hosts on your server.

# httpd.conf or srm.conf
AddType audio/mpeg mp3 MP3
AddType audio/playlist m3u M3U
AddType audio/x-scpls pls PLS
AddType application/x-ogg ogg OGG

####################################################

I also had to insert these entries into httpd.conf
You may not need to do this.

PerlModule Apache::MP3
PerlModule MP3::Info

And to finish off, insert the following into the
container you will be using to host your music streaming site.

####################################################

<VirtualHost>
your_site_data
#
# Music alias dir
#
Alias /mp3/ "/path_to_your_music/"
#
<Directory "path_to_your_music">
Options Indexes Includes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</VirtualHost>

Where path_to_your_music is the location of the music
on your web server - this ** absolutely must ** be outside
of your web directories - this is to prevent unwanted
browsing of your music collection.
The "alias" parameter above allows you to do this.

####################################################

This will create an alias of mp3 on your site as follows:

http://www.yoursite.com/mp3/

Use the command "perldoc Apache::MP3" (no quotes) to obtain more
useful information regarding additional parameters you can set.

Powered by Website Baker