Installing and running Red5

From Red5Wiki

Jump to: navigation, search

Once Red5 is running, you're OK... but getting it installed and running correctly can be a pain! Unfortunately the documentation that comes with Red5, and on the Red5 site itself (at the time of writing) is woefully out of date, and talks about compiling Red5 from source using Apache 'ant'. You DO NOT, repeat DO NOT need to do this if you are just running Red5 after downloading one of the official releases. Below are instructions for getting Red5 installed and running on various platforms.

Windows

To install Red5 successfully on Windows machine, you need to obtain the executable file from the Red5 Google Code page. Also, ensure you have administrator user privilege on the machine.

- Prior to installing Red5, make sure you have the latest Java JRE installed.

- After installing Java JRE, specify the PATH variable that points to the java.exe file inside the Java /bin/ folder (e.g. c:\Program Files\Java\bin\). This can be specified under Start -> Control Panel -> System -> Advanced -> Environment Variables , look under the section PATH

- Requirement under certain Windows OS is to create the TEMP folder if you wish to install the sample demos: C:\WINDOWS\SYSTEM32\CONFIG\SYSTEMPROFILE\APPDATA\LOCAL\TEMP\

- Install Red5 application as instructed, make sure to specify the machine IP for the IP address. The default Red5 Port is 5080, but can be set to any other port that is not used by the OS.

- Red5 is not typically started up by default, so to start it click on Start -> Control Panel -> Administrative Tools -> Services and look for the Red5 services, right click on it and choose START.

Linux (Fedora / RedHat / CentOS)

So (at the time of writing), the Red5 team offer a .deb installer for Debian/Ubuntu, but nothing for RedHat-based OSes (Fedora, RedHat, CentOS). Annoying, right? Well unsurprisingly, Red5 runs very similarly on RedHat-based OSes as it does on Debian-based.

First, you need to install Java if it hasn't already been installed. I wouldn't try to get it through a repository. You can get a self-extracting file that will install an RPM of Java from java.com here... you should be downloading the 'Linux RPM (self-extracting file)' link, resulting in a file ending in '[...]rpm.bin'. Then just execute that .bin file to install Java (you may need to agree to a license first). Do a 'cd' into the same dir as the bin and run eg. './java-installer-file-rpm.bin'.

Once Java's installed, you'll want to download the 'Tarball' release of Red5 from their downloads page. This file basically contains all that red5 needs to run as a service, and so once downloaded it's just a case of unzipping it to the appropriate directory. As the scripts given on this page assume that it will be installed to /usr/lib/red5, I suggest you unzip it there. Once it's unzipped, the file '/usr/lib/red5/red5.sh' should exist.

Now, to get red5 running as a service on RedHat-based OSes is a bit more tricky. Debian and Ubuntu come with a handy application called start-stop-daemon that simplifies the process of managing daemon/service processes on the system. The Red5 .deb installer creates an init.d script that utilizes this application... this application is not available on RedHat-based OSes.

So, a rather painstaking modification of that init.d file is needed to get it working without start-stop-daemon. Below is one that works acceptably well:

#! /bin/sh
#
# chkconfig: 345 85 15
# description: Controls Red5 Flash media server as a Linux service.
#
# red5         red5 initscript (adapted by Jez for RedHat/CentOS)
#
# Author:      Simon Eisenmann <simon@struktur.de>
#              Jeremy Morton <jez9999@gmail.com>
#

RETVAL=0
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="Red5 flash streaming server"
NAME=red5
RED5_HOME=/usr/lib/red5
DAEMON=$RED5_HOME/$NAME.sh

# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0

# Read config file if it is present.
if [ -r /etc/default/$NAME ]
then
    . /etc/default/$NAME
fi

#
#    Function that starts the daemon/service.
#
d_start() {
    if [ -f /var/run/red5.pid ]; then
        RED5PID=`cat /var/run/red5.pid`
        RED5RUNNING=`ps -fp $RED5PID | grep $RED5PID`
        if [ "$RED5RUNNING" != "" ]; then
            echo "Can't start red5; already active (PID $RED5PID)..."
            return 0
        else
            echo "Can't start red5; not active, but PID file (/var/run/red5.pid) has not been deleted."
            return 1
        fi
    fi

    mv /var/log/red5.log /var/log/red5_previous.log
    cd $RED5_HOME
    export LD_LIBRARY_PATH=$RED5_HOME/webapps/
    su -c "$RED5_HOME/red5.sh > /var/log/red5.log 2>&1 & /bin/echo \$! > /var/run/red5.pid" root
    RETVAL=$?
    echo
    return $RETVAL
}

#
#    Function that stops the daemon/service.
#
d_stop() {
    cd $RED5_HOME
    $RED5_HOME/red5-shutdown.sh
    RETVAL=$?
    rm /var/run/red5.pid
    echo
    return $RETVAL
}

case "$1" in
  start)
    echo -n "Starting $DESC: $NAME"
    echo
    d_start
    echo "."
    ;;
  stop)
    echo -n "Stopping $DESC: $NAME"
    echo
    d_stop
    echo "."
    ;;
  restart|force-reload)
    echo -n "Restarting $DESC: $NAME"
    echo
    d_stop
    sleep 1
    d_start
    echo "."
    ;;
  *)
    echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
    exit 1
    ;;
esac

exit 0

Write this to the file '/etc/init.d/red5', then chmod and chown it to make sure it's owned by root:root, and chmodded 755. The Debian init.d script that gets written also references a file called /etc/default/red5 and I've kept that referenced in the init.d script above. Here's what the Debian install of Red5 writes to the /etc/default/red5 file (there's not much there... but you might want to create it on your system too anyway):

JAVA_HOME=/usr
CLASSPATH=

Finally, you need to register the init.d script as a service. As it's now sitting in /etc/init.d and has a '# chkconfig' line, the chkconfig utility can be used to register it as a service on RedHat-based OSes. Run 'chkconfig red5 reset'. This should setup that red5 script as a service. You can check that it's there by running 'chkconfig --list | grep red5'. You should see a line showing runlevels 0-6 and whether the red5 service is on or off for that runlevel. It should be set to 'on' for runlevels 3, 4, and 5, after having done that chkconfig reset. This means the red5 service will start at bootup for most normal modes of system operation. If you wish to disable the service starting at bootup, you can run 'chkconfig red5 stop', and of course you can run 'chkconfig red5 reset' again to make it run at bootup again. Now, to manually start, stop, and restart the service from the commandline, you can run 'service red5 start', 'service red5 stop', and 'service red5 restart'.

That's it! You should be ready to start using Red5. Try connecting to http://(yourserver.com):5080/ to check that it's working.

Linux (Debian / Ubuntu)

Successfully done with latest SVN release as of today on Ubuntu 8.04 64bit. Slightly modified from [1]

Download and Install Java

apt-get -y install openjdk-6-jdk openjdk-6-jre


Download and Install Ant

cd /usr/src; wget http://mirrors.kahuki.com/apache/ant/binaries/apache-ant-1.8.1-bin.tar.bz2 tar jxvf apache-ant-1.8.1-bin.tar.bz2 mv apache-ant-1.8.1 /usr/local/ant

ln -s /usr/lib/jvm/java-6-openjdk /usr/lib/jvm/java

Install SVN (Skip if SVN is already installed)

apt-get -y install subversion


Download and install Red5


svn co http://red5.googlecode.com/svn/java/server/tags/0_9_1/ red5 mv red5 /usr/share/ cd /usr/share/red5

ant prepare ant dist cp -r dist/conf .


NOTE: This will install version 0.9.1 of Red5. If you wish to use a previous version, go to - http://red5.googlecode.com/svn/java/server/tags/ and get the link to the version of Red5 you wish to use and substitute it in the "svn co" field.


Change Permissions of red5.sh

chmod a+x red5.sh


Start Red5

./red5.sh


If everything is working fine, test Red5 at http://yourip:5080


Make the Init script

vi /etc/init.d/red5

Copy and paste the code below. If your using putty, press ESC and then type :wq to save the init file.

Code start:

 #! /bin/sh
 # init script for Red5
 # /etc/init.d/red5
 RED5_USER=root
 RED5_HOME=/usr/share/red5
 RED5_PROG=red5
 test -x $RED5_HOME/$RED5_PROG.sh || exit 5
 case "$1" in
     start)
         echo -n "Starting Red5"
         echo -n " "
         cd $RED5_HOME
         su -s /bin/bash -c "$RED5_HOME/$RED5_PROG.sh &" $RED5_USER
     ## su -s /bin/bash -c "$RED5_HOME/$RED5_PROG.sh > start.log &" $RED5_USER
         sleep 2
         ;;
     stop)
         echo -n "Shutting down Red5"
         echo -n " "
         su -s /bin/bash -c "killall -q -u $RED5_USER java" $RED5_USER
         sleep 2
         ;;
     restart)
         $0 stop
         $0 start
         ;;
 esac


Code Finish:


Change the permissions of the init file


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


Restart and test Red5

/etc/init.d/red5 restart

Personal tools