3 min read

Tutorial installing Icecast2 - Online radio with autodj

This evening, I’m contacted by one of my friend via YahooMessenger because I put a status about searching an Indonesia VPS provider, and from the conversation he teach me to install Icecast in a vps.
The tutorial is based from here, and since this is the first time I’m configuring Icecast, I thought it’s a good way to wrote the tutorial. And this is performed in a VPS from ServerHub with the following :

Promo Servers - LEB-1R Linux 1
1 CPU Core
1024MB RAM
512MB Burst
65GB Diskspace
1000GB Bandwidth
100Mbit Port Speed
1 IPv4 Address
8 IPv6 Addresses
OpenVZ/SolusVM
$3.99/Month
Location : Phoenix
Operating System : Debian 6 32bit

Initial setup for preparing the required package for my Debian 6 VPS :

# apt-get install gcc make zip openvpn build-essential pkg-config libxml2-dev icecast2 ezstream

 
Configuring Icecast2
Icecast2 configuration is located at /etc/icecast2/icecast.xml, and we need to configure the password in that file

<authentication>
 <!-- Sources log in with username 'source' -->
 <source-password>your_passworda</source-password>
 <!-- Relays log in username 'relay' -->
 <relay-password>your_password</relay-password>
<!-- Admin logs in with the username given below -->
 <admin-user>admin</admin-user>
 <admin-password>password_for_admin</admin-password>
 </authentication>

 
 Starting Icecast2 after reboot
To make Icecast2 started automatically after reboot, we need to change the Icecast startup file /etc/default/icecast2

# Edit /etc/icecast2/icecast.xml and change at least the passwords.
# Change this to true when done to enable the init.d script
ENABLE=true

 
Test run the Icecast2
We need to make sure that Icecast can run, to start it, use the following command :

# service icecast2 restart
or
# /etc/init.d/icecast2 restart

By default, Icecast will run at port 8000, so try to visit your IP:8000 , http://ip.address.of.vps:8000
 
Creating Playlist and configuring ezstream
We will use an addon named ezstream, and this is the tutorial for installing ezstream :

Install libogg :
# wget http://downloads.xiph.org/releases/ogg/libogg-1.3.1.tar.gz
# tar xf libogg-1.3.1.tar.gz
# cd libogg*
# ./configure
# make && make install
Install libvorbis :
# wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.3.tar.gz
# tar xf libvorbis-1.3.3.tar.gz
# cd libvorbis*
# ./configure
# make && make install
Install libshout :
# wget http://downloads.xiph.org/releases/libshout/libshout-2.3.1.tar.gz
# tar xf libshout-2.3.1.tar.gz
# cd libshout*
# ./configure
# make && make install
Install ezstream :
# wget http://downloads.xiph.org/releases/ezstream/ezstream-0.5.6.tar.gz
# tar xf ezstream-0.5.6.tar.gz
# cd ezstream*
# ./configure
# make && make install

Saving mp3 files. we can use any folder, but for this tutorial I use /home/mp3

# cd /home
# mkdir mp3
# cd /home/mp3

Creating playlists :

# nano /home/mp3/playlist.txt
/home/mp3/song1.mp3
/home/mp3/song2.mp3
/home/mp3/song3.mp3
/home/mp3/song4.mp3

 
Configuring ezstream
By default, we already have ezstream configuration examples located at  /usr/share/doc/ezstream/examples, so we can copy and configure it :

# cp /usr/share/doc/ezstream/examples/ezstream_mp3.xml /root/ezstream_mp3.xml

 

# nano /root/ezstream_mp3.xml
<!--
 EXAMPLE: MP3 playlist stream WITHOUT reencoding
This example streams a playlist that contains only MP3 files. No other file
 formats may be listed. Since ezstream will not be doing any reencoding, the
 resulting stream format (bitrate, samplerate, channels) will be of the
 respective input files.
 -->
<ezstream>
 <url>http://ip.address.of.vps:8000/stream</url>
 <!--
 If a different user name than "source" should be used, set it in
 <sourceuser/>:
 -->
 <!-- <sourceuser>mr_stream</sourceuser> -->
 <sourcepassword>your_password</sourcepassword>
 <format>MP3</format>
 <filename>/home/mp3/playlist.txt</filename>
 <!-- Once done streaming playlist.m3u, exit: -->
 <stream_once>0</stream_once>
 <!--
 The following settings are used to describe your stream to the server.
 It's up to you to make sure that the bitrate/samplerate/channels
 information matches up with your input stream files. Note that
 <svrinfoquality /> only applies to Ogg Vorbis streams.
 -->
 <svrinfoname>Server Name</svrinfoname>
 <svrinfourl>http://www.yoururl.com</svrinfourl>
 <svrinfogenre>RockNRoll</svrinfogenre>
 <svrinfodescription>As you wish</svrinfodescription>
 <svrinfobitrate>64</svrinfobitrate>
 <svrinfochannels>5</svrinfochannels>
 <svrinfosamplerate>44100</svrinfosamplerate>
 <!--
 Prohibit the server to advertise the stream on a public YP directory:
 -->
 <svrinfopublic>0</svrinfopublic>
</ezstream>

Set the permisson of ezstream_mp3.xml to 0644 or 0755

# chmod 0644 ezstream_mp3.xml
or
# chmod 0755 ezstream_mp3.xml

 
Starting ezstream
We need to keep ezstream running while we’re streaming the mp3, so we need to run it in background by using “screen”.

# screen -S "stream"
# ezstream -c /root/ezstream_mp3.xml

Now we have our Icecast ready, to get the playlist, try to visit http://:ip.address.of.vps:8000/stream.m3u or http://ip.address.of.vps:80000/stream.xspf