Run the following commands as (root, any superuser)Note: To upgrade to future releases just do the first 3 steps, and nothing else in this document.
- mv _mp3db /path_to_your_mp3s
- mv ./_mp3db/helpers/MP3db-backend.pl /usr/bin
- mv ./MP3db.pl /path_to_your_mp3s
- ln -s /path_to_your_mp3s/MP3db.pl /path_to_your_mp3s/MP3db.pls
- ln -s /path_to_your_mp3s/MP3db.pl /path_to_your_mp3s/MP3db.mp3
Run the following command as (root, any superuser). The -p assumes you have set up MySQL with a password for the user account you're using.Edit /usr/bin/MP3db-backend.pl with whatever text editor you prefer and find the section at the top labled "YOUR ATTENTION PLEASE!!!!". Below this line, configure your SQL username and password. Here's an example:
- mysqladmin -p create MP3db
my $sqluser = 'my_username';Run the following commands as (root, any superuser)
my $sqlpass = 'sqlpassword111';That last command may take some time to scan all of your mp3s, depending on the size of your collection and the speed of your computer. A time of 10 minutes or more would not be unreasonable.
- perl /usr/bin/MP3db-backend.pl --initdb
- perl /usr/bin/MP3db-backend.pl --dir /path_to_your_mp3s
NOTE: As you make changes to your MP3 collection such as adding or deleting mp3s or changing the info inside the tags, these changes will not appear in the database until you re-scan your collection. I recommend setting up a cron job to run the backend script on a nightly basis.
Please follow the section below that corresponds to the version of Apache you have installed.Apache 1.3.x
- Edit your httpd.conf file and locate the string "AddType" Below the existing AddType lines add the following lines:
AddType audio/mpeg mp3 MP3
AddType audio/x-scpls pls PLS- Also in httpd.conf, locate the first "<Directory" and below that block add the following:
<Directory /path_to_your_mp3s> Options FollowSymLinks +ExecCGI -Indexes Order allow,deny Allow from all DirectoryIndex MP3db.pl PerlSendHeader Off <Files ~ "(MP3db\.pl|MP3db\.pls|MP3db\.mp3)$"> SetHandler perl-script PerlHandler Apache::Registry </Files> </Directory>- Restart apache
Apache 2.x
- Edit your httpd.conf file and locate the string "AddType" Add the following lines below that line:
AddType audio/mpeg mp3 MP3
AddType audio/x-scpls pls PLS- Edit httpd.conf and locate the "<Directory" block you added that contains the MP3db settings. Delete the entire <Files> </Files> sub-block and replace it with the following:
<Directory /path_to_your_mp3s> Options FollowSymLinks +ExecCGI -Indexes Order allow,deny Allow from all PerlSendHeader Off DirectoryIndex MP3db.pl <Files ~ "(MP3db\.pl|MP3db\.pls|MP3db\.mp3)$"> SetHandler perl-script PerlResponseHandler ModPerl::Registry </Files> </Directory>- Restart apache
Browse to http://yoursite.dom/path_to_your_mp3s and if the MP3db main page loads, you're all done! If not, read the directions again and check your error log for details on where you may have gone astray.
- A unix based OS such as Linux or FreeBSD
- MySQL Version 4 or higher
- Perl version 5.8 or higher
- Apache with mod_perl (compatible with versions 1.33.x and 2.x)
- The following perl modules (available from CPAN)
- CGI
- CGI::Session
- CGI::Cookie
- Benchmark::Timer
- DBI
- DBD::mysql
- MP3::Info
- MP3::Tag
- List::Compare
Some of the pages and playlists generated by the script contain a lot of data, sometimes totaling half a meg just to browse a list of all your artists. Over slower connections the size of the pages can cause long wait times as well as buffering problems if you load a large page while streaming a song. The solution is to implement compression in Apache. Below are solutions for both Apache versions.Apache 1.3.x
- Install the CPAN modules Apache::OutputChain and Apache::GzipChain
- Edit httpd.conf and locate the <Directory block you added that contains the MP3db settings. Delete the entire <Files> </Files> sub-block and replace it with the following:
<Files ~ "(MP3db\.pl|MP3db\.pls)$"> SetHandler perl-script PerlHandler Apache::OutputChain Apache::GzipChain Apache::Registry </Files> <Files ~ "(MP3db\.mp3)$"> SetHandler perl-script PerlHandler Apache::Registry </Files>Apache 2.x
- Install the Apache2 module mod_deflate (if not already installed)
- Edit httpd.conf and locate the <Directory block you added that contains the MP3db settings. Under the line that starts with DirectoryIndex add the following line:
AddOutputFilterByType DEFLATE text/html text/plain audio/x-scpls audio/playlist text/css application/x-javascript
The apache set up can be done in many ways, using <Directory, <Location or even <VirtualHost configurations. If you know how to set them up, use whichever suits you best. I prefer a virtual host myself.
This program uses code or software from the following authors
- Lincoln D. Stein for Apache::MP3 (http://search.cpan.org/dist/Apache-MP3/)
- Jeroen Wijering for his Flash mp3 player (http://www.jeroenwijering.com/)
- Sam Stephenson for Prototype (http://prototype.conio.net/)
- Thomas Fuchs for script.aculou.us (http://script.aculo.us/)
- Dragon Labs for Octopus Engine (http://www.dragon-labs.com/)