Icecast

Introduction
Icecast is a tool for setting up streaming audio over the Internet. (Icecast is an open source alternative to Shoutcast.) Unlike other all-in-one solutions, however, icecast only provides the network capabilities and requires another tool to provide the actual music stream. In this tutorial, mpd will be used to provide the necessary encoding/streaming capabilities. Just know that there may be other ways to do this.

Installation
Icecast requires the music player daemon (mpd) to provide the music stream on the local machine, additionally, some tool is required to control mpd. In this case we will just use mpc, although much more advanced UI's exist for mpd. Thus, start by installing mpd, mpc and icecast.

Note that for good codec support, the ffmpeg use flag should be included and ffmpeg should include use flags for all the formats you need. I would recommend just going ahead and adding the following use flags,

then running

to make sure you get everything you need, otherwise you may get failed to open error from mpd.

Configuration
Now that everything is installed. Modify /etc/icecast2/icecast.xml and change all the hackme passwords to something else. In /etc/mpd.conf uncomment the icecast section, then re-comment either quality or bitrate (only one can be set). You also need to change hackme there to the password you set in the icecast.xml file. Obviously other parameters may be changed at a later time for better quality etc, but for now just make those changes to get everything working. Finally you should uncomment the lines follow_outside_symlinks and follow_inside_symlinks so that a symlink in the /var/lib/mpd/music directory will be properly followed. When you are done, make a link in /var/lib/mpd/music to your music directory:

Running
Now start icecast:

Now if you point your browser to localhost:8000 click admin and then list mountpoints you should see and empty section. If for some reason no page comes up for localhost:8000 then either you have entered a different port in /etc/icecast2/icecast.xml or for some reason icecast failed to start. You should look at the log in /var/log/icecast.

Now you are ready to start mpd:

There may be a warning about the fact that you are missing a database file, that is normal the first time you start mpd. Other errors, however may have to be dealt with, usually by consulting the log file: /var/log/mpd/mpd.log

If mpd started, it will begin by generating a database of all the music in /var/lib/mpd/music, which because of the symlink there, should include all your music. To add other directories, simply add more symlinks. If you type run mpc without arguments it should say updating database:

Once the database is updated you can add music to the playlist by typing

Now you should check to make sure the playlist isn't empty you can type:

which should give you a long list of files. Once you start mpc playing the mountpoint will show up in the icecast web interface. So as before go to localhost:8000 in a browser and go to the server status screen and it should no longer be empty, nor should the mountpoints. Now to test that the server is actually streaming you can test it:

Yellow Pages
It is possible to list your streams in a directory listing (Yellow Pages). Icecast2 has it own YP directory located at http://dir.xiph.org. To be able to add your stream in directory listings, you have to tell mpd that the stream is public:

Afterwards, you have to tell icecast where to send the stream: