Run a DIY Internet Radio Station with Icecast [Linux]

So you’re a live DJ or musician, and you want to get some exposure for your skills online. There are various services you can sign up for to host Internet radio stations – Caster.fm and Shoutcast come to mind – but getting their tools to work on Linux is not always trivial.

A fine alternative is Icecast, a GPL-licensed streaming software with an online radio station directory. You can download it here or install it through your Linux distribution’s package manager.

It’s not enough to just install Icecast; you also need a source client, which will connect to the Icecast server and manage the details of the radio station. A number of these exist, but the one I found easiest to use for a simple radio station was the command-line client Ezstream. In this tutorial, I’ll walk you through setting up both Icecast and Ezstream.

First open the file “/etc/icecast2/icecast.xml” with root privileges. You can leave most of it alone, but you’ll want to at least change the authentication passwords. In my case, I also changed the port number to 8001 because the default, 8000, was already in use.

icecast configuration

Now start the Icecast server:

sudo /etc/init.d/icecast start

On my system, the program is called “icecast,” but on yours it might be called “icecast2.”

The server is now running, but there is no audio stream. You can access your Icecast administration page by opening your browser and visiting 127.0.0.1:8000 (replacing “8000” appropriately if you changed your port number). Enter the username “admin” and the password you set up in icecast.xml. The administration page initially looks like this:

icecast administration

First you need to make a playlist from some or all of the music you have on your system. If you don’t already have one, here’s a simple command to make a playlist from all of the .mp3 files in your music directory, in alphabetical order:

find ~/Music -name *mp3 -type f > ~/Music/Playlists/icecast-playlist.txt

Icecast also lets you stream in other formats, such as Ogg Vorbis, but I used the mp3 format because that’s what most of my music files are.

If you open the resulting “icecast-playlist.txt” file with a text editor, you’ll see that it’s just a list of tracks with their complete file paths. You can edit this as you please.

Now you’re ready to edit the Ezstream configuration file. Make a directory for it somewhere in your home directory. For example:

mkdir ~/.ezstream

The example configuration files are saved in “/usr/share/doc/ezstream” or “/usr/share/doc/ezstream-[version]” in a directory called “examples”. Copy one example file of your choosing into the directory you just made:

cp /usr/share/doc/ezstream-0.5.6/examples/ezstream_mp3.xml ~/.ezstream

Now open up the copy for editing. There are a few things to change here. If you are using a non-standard port, you’ll have to change that in the <url> section on line 10. Fix your <sourcepassword> section to match the password you created for Icecast, and edit the <filename> section to point to your playlist file.

Scroll down to the server settings to change the name and description of your station and optionally add a link to your website. At the very end of the file is an option to make your stream public. By default, it looks like this:

<svrinfopublic>0</svrinfopublic>

If you want your station to be listed on the public Icecast directory, change the “0” to “1.” For this to actually work, you need to set up port forwarding in order to bypass any firewall rules that restrict outside access to your system. I won’t go into that here because the way to set it up varies according to your network settings.

Once you’re satisfied with your ezstream_mp3.xml configuration file, start Ezstream and point it to that file:

ezstream -c ~/.ezstream/ezstream_mp3.xml

Icecast and Ezstream should now be connected! Go back to 127.0.0.1:8000 in your browser. This time, you should see some information:

icecast status

You can now listen to your own stream by downloading the .m3u file and opening it in a supported player, such as Audacious, or directly opening the URL in your media player.

icecast-audacious

If someone on your LAN wants to connect to your stream, they must use the same URL but substituting your LAN IP address for “127.0.0.1,” which is just the local loopback address and is the same on every system.

I hope this was as fun for you to set up as it was for me. Do you have an online radio station? How did you set it up? Do you have any tips for beginners?