Howto install red5 server and java on Ubuntu Server 14.04 LTS

Install Oracle Java 8:

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer

Webupd8 ppa repository also providing a package to set environment variables.

sudo apt-get install oracle-java8-set-default

Install Red5:

sudo apt-get install libtomcat6-java

download tarball from:

https://github.com/Red5/red5-server/releases/download/v1.0.6-RELEASE/red5-server-1.0.6-RELEASE-server.tar.gz

extract it somewhere. i.e. under /opt with tar xvzf command

/opt/red5-server-1.0.6-RELEASE/

create a file named red5 under /etc/init.d

sudo vi /etc/init.d/red5

add these lines:

#!/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-server-1.0.6-RELEASE/ && nohup ./red5.sh > /dev/null 2>&1 &
  echo 'Service started' >&2
}

stop() {
  cd /opt/red5-server-1.0.6-RELEASE/ && ./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 this file and exit then make it executable

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

then turn the autostart on if you prefer it to automatically start during bootup

sudo sysv-rc-conf red5 on

Now you can start/stop the red5-server with the service command

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

Please note, if you are setting up a prod-environment you should also create a dedicated user/group running this process so that it is not run under root-privileges.