[LINUX] Create your own IP Radio Station

OK, so the idea of this post is to create a self-hosted low-bandwidth radio station, that can even work on 33.6Kbps modems.

So, let’s start with:

  1. Hardware

1 x vCPU

2 GB of RAM

128 GB Storage

2. Software and configs

  • OS: Ubuntu Server 24.04.3 LTS
  • IceCast

sudo apt update
sudo apt -y upgrade
sudo apt install -y icecast2

  • enable IceCast daemon

sudo nano /etc/default/icecast2

ENABLE=true

  • verify settings on IceCast’s main config file

sudo nano /etc/icecast2/icecast.xml

  • Start Icecast + enable on boot

sudo systemctl enable –now icecast2
sudo systemctl status icecast2 –no-pager

 

  • Open the IceCast web page

From your PC browser:

http://YOUR_SERVER_IP:8000/

Admin page:

http://YOUR_SERVER_IP:8000/admin/

user: admin

password: whatever you set as <admin-password>

  • Create the music folder + IceCast user

sudo adduser –system –group –no-create-home icecast

sudo mkdir -p /srv/radio/music
sudo chown -R icecast:icecast /srv/radio

sudo systemctl restart icecast2

  • Install Liquidsoap

sudo apt update
sudo apt install -y liquidsoap

Test install using: liquidsoap –version

  • Create the Radio script

sudo nano /srv/radio/radio.liq

Config sample:

 

set(“log.stdout”, true)
set(“log.level”, 3)

# Folder-based playlist
music = playlist(
“/srv/radio/music”,
mode=”random”,
reload=10
)

# Output to Icecast (dial-up safe)
output.icecast(
%mp3(
bitrate=24,
samplerate=22050,
stereo=false
),
host=”localhost”,
port=8000,
password=”SOURCE_PASSWORD_HERE”,
mount=”/low.mp3″,
music
)

You can test the config manually: liquidsoap /srv/radio/radio.liq and you should see an output like:

Connecting mount /low.mp3
Source connected

Add / remove music (live, no restart)

Just copy files into:

/srv/radio/music

  • Run Liquidsoap automatically (systemd service)

sudo nano /etc/systemd/system/radio.service

[Unit]
Description=Icecast Radio (Liquidsoap)
After=network-online.target icecast2.service
Wants=network-online.target

[Service]
User=icecast
Group=icecast
ExecStart=/usr/bin/liquidsoap /srv/radio/radio.liq
Restart=always
RestartSec=3

[Install]
WantedBy=multi-user.target

 

Then enable it using:

sudo systemctl daemon-reload
sudo systemctl enable –now radio.service

 

  • Confirm the stream is LIVE on Icecast

curl -I http://127.0.0.1:8000/low.mp3

You want to see HTTP/1.0 200 OK (or 200).

From your PC:

Open: http://YOUR_SERVER_IP:8000/low.mp3 in VLC or browser.

 

  • Install an HTML audio player page

sudo apt install -y apache2
sudo ufw allow 80/tcp

 

sudo nano /var/www/html/player.html

 

<!doctype html>
<html>
<head>
<meta charset=”utf-8″>
<title>DialRadio</title>
</head>
<body>
<h1>DialRadio (24 kbps)</h1>

<audio controls preload=”none”>
<source src=”http://VM_LAN_IP:8000/low.mp3″ type=”audio/mpeg”>
Your browser does not support audio.
</audio>

<p>Click ▶ Play to start the stream.</p>
</body>
</html>

  • Apache Redirects

Goal: to redirect from: http://<your server IP> to: http://<your server IP>/player.html

 

sudo nano /etc/apache2/sites-available/000-default.conf

Inside <VirtualHost *:80>, add:

RedirectMatch ^/$ /player.html

Example:

<VirtualHost *:80>
DocumentRoot /var/www/html

RedirectMatch ^/$ /player.html
</VirtualHost>

Save and restart:

sudo systemctl restart apache2

Now enjoy listening to your own radio station by accessing: http://<your server IP> !