Setup Red5 Media Server on CentOS 7

Updated on June 8, 2018
Setup Red5 Media Server on CentOS 7 header image

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 CentOS 7.

###Requirements

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

Before installing any packages on the CentOS server instance, let’s start by ensuring your system is up-to-date.

yum clean all
yum -y update

###Install Java

First, let's download the latest Java SE Development Kit 8 release from its official download page.

cd /opt/
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u161-b12/2f38c3b165be4555a1fa6e98c45e0808/jdk-8u161-linux-x64.tar.gz"
tar xzf jdk-8u161-linux-x64.tar.gz

Install Java using alternatives.

alternatives --install /usr/bin/java java /opt/jdk1.8.0_161/bin/java 2
alternatives --config java

Setup javac and jar commands path using alternatives.

alternatives --install /usr/bin/jar jar /opt/jdk1.8.0_161/bin/jar 2
alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_161/bin/javac 2
alternatives --set jar /opt/jdk1.8.0_161/bin/jar
alternatives --set javac /opt/jdk1.8.0_161/bin/javac

####Setup global environment variables.

Setup JAVA_HOME variable:

export JAVA_HOME=/opt/jdk1.8.0_161

Setup JRE_HOME variable:

export JRE_HOME=/opt/jdk1.8.0_161/jre

Setup PATH variable:

export PATH=$PATH:/opt/jdk1.8.0_161/bin:/opt/jdk1.8.0_161/jre/bin

###Install Red5

Obtain the latest version of the Red5 server.

cd ~
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 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 and 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 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.