Create your own Linux Radio Station

Jarret B

Well-Known Member
Staff member
Joined
May 22, 2017
Messages
340
Reaction score
367
Credits
11,754
Streaming audio to your local network or even to the Internet is possible on Linux. For those who like to listen to music wherever they go makes having your own radio station very handy.

Keep in mind that this will use some of your network bandwidth, but it is a nice feature to have when you want music handy everywhere.

Getting Ready

There are a few programs you will need to download and have ready to install to your system.

The programs are:

  1. IceCast - http://www.icecast.org/download/
  2. EZStream - http://www.icecast.org/ezstream/
  3. libshout - http://www.icecast.org/download/
  4. libvorbis - https://www.xiph.org/downloads/
  5. libogg - https://www.xiph.org/downloads/
Download the two packages and place them into a folder which is easily accessible for extraction and installation.

NOTE: I placed all the files in the same folder to make installation easier. The instructions, which follow later, assume the files are all extracted to the same directory.

The files I downloaded are named as follows (the names will change when newer versions are released):
  1. icecast-2.4.3.tar.gz (2.4 MB)
  2. ezstream-0.6.0.tar.gz (250.4 KB)
  3. libshout-2.4.1.tar.gz (504 KB)
  4. libvorbis-1.3.5.tar.gz (1.6 MB)
  5. libogg-1.3.2.tar.gz (537 KB)
Next, you will need to extract the files so they can be used. To extract the files open a Terminal and change the directory to the folder where you saved the downloads. For the files listed which I downloaded, the commands to extract the files are as follows:
  • tar -xf icecast-2.4.3.tar.gz
  • tar -xf ezstream-0.6.0.tar.gz
  • tar -xf libshout-2.4.1.tar.gz
  • tar -xf libvorbis-1.3.5.tar.gz
  • tar -xf libogg-1.3.2.tar.gz
Installation

To perform the installation do the following steps in the order that they appear:

Debian

sudo apt-get update
sudo apt-get install libxslt-dev
cd libogg-1.3.2
./configure && make
sudo make install
cd ..
cd libvorbis-1.3.5
./configure && make
sudo make install
cd ..
cd icecast-2.4.3
./configure && make
sudo make install
cd ..
cd libshout-2.4.1
./configure && make
sudo make install
cd ..
sudo apt-get install ezstream
sudo apt-get install lame
sudo apt-get install madplay


Red Hat (CentOS 7)

yum install libxslt-devel
cd libogg-1.3.2
./configure && make
sudo make install
cd ..
cd libvorbis-1.3.5
./configure && make
sudo make install
cd ..
cd icecast-2.4.3
./configure && make
sudo make install
cd ..
cd libshout-2.4.1
./configure && make
sudo make install
cd ..
sudo yum install ezstream
sudo yum install lame
sudo yum install madplay


Configuration

To configure the services the way you need it to be, perform the following:

sudo gedit /usr/local/etc/icecast.xml

NOTE: Instead of ‘gedit’ replace the name with your text editor for your ditro. For example, with CentOS you would probably use ‘pluma’.

Look for the section as shown in Figure 1. Change the ‘<source-password>’, ‘<relay-password>’ and ‘<admin-password>’. You can also change the ‘<admin-user>’ as you need to make it a little harder for someone to gain access to your streaming service.

If you perform a search for ‘8000’ you should find two occurrences. You can change the default port to another number other than ‘8000’ so your streaming server is not at the defaults.

Find the line which is ‘<hostname>localhost</hostname>’ and change ‘localhost’ to your IP Address.

Further down the XML file will be three lines which start with ‘<logdir>’, ‘<webroot>’ and ‘<adminroot>’. Make sure the folders specified on these lines exist. Also, create the folder ‘/usr/local/var/log/icecast’. You will also need to take ownership of the last folder ‘icecast’.

Before we copy and edit the configuration file, we need to create your playlist. Copy all MP3 files into the ‘HOME/Music’ folder. In a Terminal you will need to enter the command ‘find -name *mp3 -type f > ~/Music/Playlist/playlist.m3u’. Once the file is created, you will need to ‘escape’ all the spaces by doing a search for ‘ ‘ and replacing it with ‘/ ‘.

Next, you need to make a folder for the EZStream configuration file. Create a folder in the HOME folder named ‘.ezstream’. Go to the folder where you extracted the EZStream compressed file. Inside is a folder named ‘examples’. Find the file ‘ezstream_reencode_mp3.xml’ and copy it to the folder ‘.ezstream’ you just created and rename is ‘ezstream_mp3.xml’. You may need to press CTRL+H to see the hidden folders (those that start with a period).

A line towards the beginning is something like ‘<url>http://localhost:8000/stream</url>’. Change ‘localhost’ to your IP Address. Change the Port number ‘8000’ to match what you made it in the ‘icecast.xml’ file. On the line with ‘<filename>’ change the entry to ‘/home/[username]/Music/Playlist/playlist.m3u’. Make sure you place your user name in the place of ‘[username]’. After this line, add a new line with the contents of ‘<playlist_program>0</playlist_program>’. Change the line with ‘<sourcepassword>’ to the same password as in the ‘icecast.xml’ file.

You can also change the contents for the four lines after <svrinfoname>’ to meet your needs.

The line for ‘<scvrinfopublic>’ is set to ‘0’. The number should be changed to a ‘1’ if you want to stream past your network to the Internet. To stream to the Internet would require that you open the port on your router that you specified in the two XML files.

Open a Terminal and type ‘icecast -c /usr/local/etc/icecast.xml’ which should start the IceCast program.

To check that it is running open a web browser and for the address type in your IP Address followed by a colon and then the port number you specified. For example, if my system had and IP Address of ‘192.168.122.102’ and a port number of ‘8002’ I would type in ‘192.168.122.102:8002’. You should see something come up with information about IceCast. If nothing appears, then look back over your ‘icecast.xml’ file and make sure your IP address is correct as well as the port number you specified.

Now to start the stream of music you need to type the following command in another Terminal: ‘ezstream -c ~/.ezstream/ezstream.xml’. You should see a few messages appear. Re-open your web browser and go back to the same page you previously had open to the IceCast Service. You should now see more information and a listing about the stream. Your system is now streaming your music.

Unless you changed the parameter for broadcasting to the Internet you will be able to only pick the stream up on your local network. Happy Streaming!
 




Top