How To Install Red5 Media Server on Ubuntu 18.04

Red5 is a dedicated media server that is open source. It is implemented in Java and allows you to run Flash-enabled applications. It can be video, audio, as well as many recordings of client streams, such as AVC + AAC, FLV and others. Before any software installation, it is recommended to update all packages on your Ubuntu instance:

apt-get update
apt-get -y upgrade

Installing Java

This can be done with the following command:

apt-get install -y default-jre unzip

Installing Red5

You can get and install the latest version of this program using the command:

https://github.com/Red5/red5-server/releases/download/v1.2.8/red5-server-1.2.8-jdk8.tar.gz

The following is the unpacking of the archive:

tar xvzf red5-server-1.2.8-jdk8.tar.gz

Then rename the extracted folder to Red5. This can be done as follows:

mv red5-server red5
cd red5

You can start the Red5 server in the background using the command:

sh red5.sh &

Autostart Red5

In order for Red5 to automatically start when the server boots, you need to create a file called red5 in the /etc/init.d directory

nano /etc/init.d/red5

Next comes an important step – adding important lines to your red5 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

The next step is to save this using the key combination CTRL + 0 and then close the file using the key combination CRTL + X. Next, you need to make the file permanent:

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

After successfully completing the previous step, you need to install the sysv-rc-conf package

apt-get install sysv-rc-conf

Then after successful installation you will need to enable Red5

sysv-rc-conf red5 on

Here you can execute commands to start, stop or restart Red5

service red5 start
service red5 stop
service red5 restart

Was this article helpful?

Related Articles

Leave A Comment?