- About Us
Ampache is a LAMP application that gives you a Web interface to your music collection, allowing you to search, rate, and play your music over the network. It even offers transcoding support to allow clients to play back lossless-encoded FLAC files from the server and stream them to clients as MP3 audio files.
Packages for Ampache are in the standard Ubuntu Hardy repository as well as a 1-Click install for openSUSE 11. No Ampache packages are in the Fedora repositories. For this article I'll build Ampache 3.4.1 from source on a 64-bit Fedora 8 machine.
I'll assume you have already installed LAMP. To set up Ampache, first extract it into your Web server's DocumentRoot, which is typically something like /var/www/html, as shown below.
# grep DocumentRoot /etc/httpd/conf/httpd.conf ... DocumentRoot "/var/www/html" ... # cd /var/www/html # tar xzvf /.../ampache-3.4.1.tar.gz # ln -s ampache-3.4.1 ampache # chown -R root.apache ampache*
Ampache uses a MySQL database, so you might as well set up a database and an administrator account with full access to that database. Make sure you change your passwords as you go.
# mysql -p mysql> CREATE DATABASE ampache; mysql> GRANT ALL ON ampache.* TO ampache@"%" IDENTIFIED BY 'ampachepass'; mysql> FLUSH PRIVILEGES; mysql> \q
To continue installation, open Ampache in your Web browser by loading http://127.0.0.1/ampache/. As you have taken care of possible file permission issues above, the only thing you need to have before you start the next phase of installation is the username and password of a MySQL account that can set up the Ampache database. The ampache user and password that you set up above is fine for this purpose. Installation is a three-step process. Step 2 asks you again for the username and password to use to connect to the database and allows you to download the ampache.cfg.php configuration file, which you must then copy to the Web server that you are running Ampache on. The below commands can be used on the machine running Ampache to install the configuration file.
# cp /.../ampache.cfg.php /var/www/html/ampache/config/ # chown root.apache /var/www/html/ampache/config/ampache.cfg.php # ls -lh /var/www/html/ampache/config/ampache.cfg.php -rw-r----- 1 root apache 19K 2008-06-27 20:42 /var/www/html/ampache/config/ampache.cfg.php
Step 3 of installation asks you to create the Ampache administrator account and password. Once you've completed this step you should see a standard Ampache login screen. Once you log in to the admin account, you should see in the row of buttons below the menu on the left side a button with a tooltip "Admin," which allows you to create new catalogs and users, set up access control, and perform other administration tasks. The main menu is on the left side of screen, the center part of the screen changes depending on what operation you are performing, and the playlist is shown on the right side of screen.
After you create your users, you need to tell Ampache where to find your music files. The "Add a Catalog" option in the admin menu asks for the catalog name and the path where the music files for that catalog are located.
Once you have added a catalog you can select the browse button (second from the left in the menu) to browse the music files in your catalogs by song name, album, artist, or other criteria. Clicking Albums from the browse menu on the left of screen showed the albums from my catalog directory correctly, and clicking the plus sign next to one of them added it to my playlist, which is shown on the far right of screen. The playlist has a small row of icons at its top for actions like starting playback, adding a new playlist, and clearing the playlist, and a dropdown menu for features such as random play and playing music that is "related" to your current playlist. By default, clicking on the play button of the playlist causes the Web browser to download an m3u playlist file. If you then open the m3u file in an application such as Amarok your playlist will appear and you can start playback. The m3u file that is downloaded includes HTTP URLs to your Ampache installation so that the audio files can be streamed from your server.
Ampache includes a Flash component to allow playback directly from within your Web browser. To use this, go to your preferences (the icon that is second from the right in your menu), go to the streaming section, and set Type of Playback to Flash player instead of the default of Stream. Once you nominate to use the Flash player, clicking on the play button of your playlist will pop up a new window with a limited playback interface and music should start playing. The Flash player supports only MP3 audio, but Ampache can transcode audio into different formats on the server for you, so you should be able to playback your FLAC files from the Flash player even when you are using a limited client machine.
Ampache ships with m4a audio transcoding enabled. An audio transcode needs four things: to be enabled, to have a source format, to have a target audio format, and to have a command that converts from the given source format into the target audio format. These configuration options are set in config/ampache.cfg.php, and options already exist for transcoding m4a, MP3, and FLAC audio, with the latter two disabled by default. I found that just by uncommenting the line
transcode_flac = true in config/ampache.cfg.php, I could play FLAC files transcoded on the server to MP3 files before being sent to the Flash player. One issue I had was that I had to enable that option to playback FLAC files, but if I left that option enabled and reverted to Streaming playback, I would still get the transcoded MP3 instead of the FLAC playback from Amarok. There is mention of explicitly enabling transcoding for only remote IP addresses but I couldn't see any information on how to enable it only for clients that are using the Flash-based player. No matter what setting I selected for Transcoding in my preferences, unless
transcode_flac = true was set in the configuration file I could not play transcoded FLAC files using the Flash player.
If you want to run the whole show from Ampache instead of downloading m3u playlist files, you can set up the Music Player Daemon on the machine that will be producing the sound and control that daemon directly from Ampache as detailed in these instructions. You can also use Amarok as your client to Ampache as detailed in the manual if you are willing to use the latest development version of Amarok.
For anyone with multiple clients, the ability Ampahce offers to move to any machine and see the same view of your music is attractive. The Flash client is a great option for allowing playback on embedded devices and set-top boxes with Flash capabilities. For a more seamless experience, using the Music Player Daemon under the control of Ampache lets you avoid the intermediate m3u files.
Ben Martin has been working on filesystems for more than 10 years. He completed his Ph.D. and now offers consulting services focused on libferris, filesystems, and search solutions.