This tutorial will guide you through the process of installing and configuring Icecast2, MPD, and ncmpcpp. First, a quick summary of the various components that make up the entire internet radio system:
Stuff you’ll need:


Before you get started, you’ll want to have the following tasks completed:
Let’s do it!

  1. Open and edit /etc/mpd.conf (or wherever your mpd install is looking for the config file)
    1. The first directive, music_directory, we can leave as default. If you want to change this so you can use alternative storage, you can do so here.
    2. Next, the playlist_directory directive is similar to the previous one; we can change it or leave it as default. Typically playlist files are only a few kilobytes in size, so they don’t take up too much space.
    3. Skip down to the log_file directive. Here, you can change the log file’s location. I recommend leaving this as the default.
    4. Skip down to the bind_to_address directive, and set it to “127.0.0.1” (with quotes). Make sure to include a space between bind_to_address and “127.0.0.1”.
    5. The port directive tells mpd which port to bind to; since we’re running both mpd and Icecast2 on the same computer, we can leave this at the default of “6600”.
    6. Jump down to the save_absolute_paths_in_playlists directive. This doesn’t matter too much. Setting this to yes won’t hurt you in the long run.
    7. Scroll a long ways down to the audio outputs section of the config file. Here is where we will detail our streams. If you don’t see this section in mpd.conf or you’re making your own mpd.conf file, use this template:
    8.                 
      audio_output {
              type            "shout"
              encoding        "ogg"                   # optional, unless you want to force a particular encoding type
              name            "Example Radio"
              host            "example.com"
              port            "8000"
              mount           "/example.ogg"
              password        "ExamplePasswordYouShouldChangeThis"
              quality         "10.0"                  # This is the defined VBR quality for the stream. Either
                                                      # use this setting for a VBR with a target quality of 10
                                                      #(numbers vary based on your encoding type).
      #       bitrate         "320"                   # Uncomment and use this to force a CBR in kbps
              format          "44100:16:2"            # SampleRateKhz:Bits:Channels (1=Mono, 2=Stereo) - Example: 44100:16:2 - *'s are also acceptable
              protocol        "icecast2"              # optional
      #       user            "source"                # optional
              description     "Example Radio Station" # optional
              genre           "Example Music Genre"   # optional
              public          "yes"                   # optional, enable this so you can be listed on stream lists
              timeout         "2"                     # optional, amount of time you will wait for the output to become available
              always_on       "yes"                   # for shoutcast or icecast, always enable this        
              
      # MORE DETAILS:
      # http://www.musicpd.org/doc/user/config_audio_outputs.html
      # http://www.musicpd.org/doc/user/output_plugins.html#shout_output
      }
      
      # copy the entire block above for another stream, only mandatory change is the mount option, all others are optional,
      # but changing the name, etc. is recommended especially for the end user's sake
      
      # if MPD throws errors about trying to output to a sound card or other physical
      # audio device, you can try this to suppress it - ALWAYS LIST THIS OUTPUT LAST
      
      audio_output {
          type "alsa"
          name "fake out"
          driver "null"
      }
      
    9. If your music or paths to your music contain non-ASCII characters you might need to define the encoding scheme here.
    10. 
      # Character Encoding ##########################################################
      #
      # If file or directory names do not display correctly for your locale then you
      # may need to modify this setting. After modification of this setting mpd
      # --create-db must be run to change the database.
      #
      filesystem_charset              "UTF-8"
      #
      # This setting controls the encoding that ID3v1 tags should be converted from.
      #
      id3v1_encoding                  "UTF-8"
      #
      
    11. Now is a good time to go through mpd.conf and check for stray braces; they can cause MPD to silently fail with no errors!

  2. Make a backup copy of /etc/icecast2/icecast.xml to your homedir or other location outside of /etc/icecast2/. Then start editing /etc/icecast2/icecast.xml.
    1. The first thing you'll want to edit will be the <location> and <admin> tags; Change the location to wherever your server is located, and change the admin tag to your email address.
    2. Take note of the <limits> section. Obviously, <clients> is the maximum amount of streaming clients that can stream from the server at any one time. <sources> is the number of different radio "stations" or "streams" you can have added to the Icecast2 server simultaneously.
    3. In the <authentication> section, change <source-password> to whatever you set in mpd.conf in the previous steps.
    4. Change the <admin-user> and <admin-password> to something secure that you can remember. This is used for the web admin portion of Icecast2.
    5. If you want your server to be on the public listings at dir.xiph.org, uncomment the following block:
    6.     <directory>
              <yp-url-timeout>15</yp-url-timeout>
              <yp-url>http://dir.xiph.org/cgi-bin/yp-cgi</yp-url>
          </directory>
      
    7. Change the <hostname> parameter to match the DNS record of the server that Icecast2 is running on. If Icecast2 is running on a server that has example.com as its domain name, put "example.com" here.
    8. Locate the first <listen-socket> block and modify it to make it look like this:
    9.     <listen-socket>
              <port>8000</port>
              <bind-address>127.0.0.1</bind-address>
              <mount>/example.ogg</mount>
          </listen-socket>
      
      (If you've defined a different stream password for each stream, define it inside the <listen-socket> block instead of the main <icecast> block using <source-password>.)
    10. Edit each block as needed:
    11. Stop and restart the mpd and icecast2 servers by calling them through your system init daemon. Generally this will mean running the following as root:
    12. /etc/init.d/icecast2 stop && /etc/init.d/mpd stop && /etc/init.d/mpd start && /etc/init.d/icecast2 start
  3. Now we need to tell MPD that we have music for it to play. As any user on the system, run ncmpcpp.
    1. ncmpcpp is set up to automatically connect to the locally running MPD instance. It will first start at the current playlist window, which is empty right now since we haven't added any files yet.
    2. Press "2" to switch to the file browser window. This will show you the contents of the /var/lib/mpd/music/ directory (or whichever music directory you told MPD to use).
    3. If the file browser is empty, press "u". This will force an update of the MPD database. It may take some time depending on how many files you have in there.
    4. To add files to the current playlist, just press "t" to toggle to select mode, use Up/Down to move the cursor, Space to highlight, then press "a" to add the files you highlighted to a playlist. You'll then be asked if you want to add these files to a new playlist or the current one.
    5. If you want to add all the files in the current directory, just press "v", then "a". The "v" key inverts the current selection.
    6. Now press "1" to go back to the current playlist. Any change you make here (if you've opened up a previously saved playlist) will not be saved in this window (use the playlist editor for that by pressing "5"). Use the following keys to start playing music:
      • Enter: Play currently highlighted song, and continue to follow current playlist.
      • "s": Stop currently playing song.
      • "p": Pause currently playing song.
      • ">": Skip to next song.
      • "<": Skip to previous song.
      • Backspace OR Ctrl+H: Restart current song from the beginning.
      • For all possible commands, you can press F1 at any time. To leave the help menu in ncmpcpp, press any window number ("1", "2", etc.)
    7. Depending on what you want to do, you can have ncmpcpp repeat the current playlist and/or pick songs to play at random. To toggle repeat mode, press "r". To toggle random mode, press "z".
  4. Finally, open your web browser and go to the IP address or domain name and the port you picked in your browser. In our example, we would go to http://example.com:8000/.
    1. You should see the streams on the main page with all the correct details, and links to a M3U file, and a XSPF file. Pick whichever format is supported by your streaming client.
    2. For a list of compatible clients, go here.
    3. You'll be prompted to download the M3U file, go ahead and do so. Open it with a supported player and you should start hearing your music!
    4. In your web browser you'll also notice an "Administration" link. This is used to manage some aspects of the streams, including who's currently listening to them. When you click on the link you'll be asked for a username and password, which you set previously in /etc/icecast/icecast2.xml.
    5. In here you can view diagnostic details about all streams as well as the server itself. You can also view any clients who may currently be connected and listening to the stream right now, and optionally kick those clients if you want.
  5. Congrats, you're done!

Need further help?