Setup Red5 Media Server on Ubuntu 16.04

Published on: Fri, Apr 27, 2018 at 12:58 pm EST

Red5 is an open source media server implemented in Java that allows you to run Flash multi-user applications such as live streaming audio/video, remote object sharing (for multiplayer games), data synchronization, recording client streams (FLV and AVC+AAC), and much more.

This article will guide you through the install and setup process for launching a Red5 Media Server on Ubuntu 16.04.

Requirements

  • A sudo user.
  • A Vultr Ubuntu 16.04 x64 server instance with at least 1 GB available memory.

Before installing any packages on the Ubuntu server instance, it is recommended that you update the system.

sudo apt-get update
sudo apt-get -y upgrade

Install Java

The recommended option for installing Java is using the version packaged with Ubuntu. Specifically, this will install OpenJDK 8, the latest version.

sudo apt-get install -y default-jre unzip

Install Red5

Obtain the latest version of the Red5 server.

cd /opt/
wget https://github.com/Red5/red5-server/releases/download/v1.0.9-RELEASE/red5-server-1.0.9-RELEASE.tar.gz

Extract the tarball.

tar xvzf red5-server-1.0.9-RELEASE.tar.gz

Rename the extracted folder to red5.

 mv red5-server red5
 cd red5

Start the Red5 server in the background.

sh red5.sh &

Now you can access the Red5 media server by using your IP address followed by port :5080. You will see the Red5 welcome page.

Configure autostart

If you want the Red5 media server to start automatically during boot, create a file named red5 in /etc/init.d.

sudo nano /etc/init.d/red5

Add the following lines to the file.

#!/bin/sh

### BEGIN INIT INFO
# Provides:             red5
# Required-Start:       $remote_fs $syslog
# Required-Stop:        $remote_fs $syslog
# Default-Start:        2 3 4 5
# Default-Stop:         0 1 6
# Short-Description:    Red5 server
### END INIT INFO

start() {
  cd /opt/red5 && nohup ./red5.sh > /dev/null 2>&1 &
  echo 'Service started' >&2
}

stop() {
 cd /opt/red5 && ./red5-shutdown.sh > /dev/null 2>&1 &
 echo 'Service stopped' >&2
}

case "$1" in
start)
    start
    ;;
stop)
    stop
;;
restart)
    stop
    start
    ;;
 *)
    echo "Usage: $0 {start|stop|restart}"
 esac

Save ("Ctrl+O") and close the file ("Ctrl+X").

Make the file executable.

sudo chmod ugo+x /etc/init.d/red5

Install the sysv-rc-conf package.

sudo apt-get install sysv-rc-conf

Turn Red5 autostart on.

sudo sysv-rc-conf red5 on

At this point you can start/stop/restart the Red5 server with the service commands.

sudo service red5 start
sudo service red5 stop
sudo service red5 restart

Finish installation

You can finish installing Red5 through your web browser. Open your web browser and navigate to URL HTTP://[your-ip-adresse:5080] with the actual IP address pointed towards your Vultr VPS. For example, you can install some of the demo applications by going to HTTP://your-ip-address:5080/installer/.

Your Red5 media server installation is now complete.