Setting up a Red5 Flash Media Server

Rate this post

This post will explain a simple process for installing a Red5 Flash Media server in a VPS or Dedicated environment.

Install Subversion and Java

yum -y install java-1.7.0-openjdk java-1.7.0-openjdk-devel
yum -y install subversion

Install Ant

(get the latest from http://ant.apache.org/bindownload.cgi)

cd /opt
wget http://apache.spinellicreations.com/ant/binaries/apache-ant-1.9.0-bin.zip
unzip ant/binaries/apache-ant-1.9.0-bin.zip
mv apache-ant-1.9.0 ant
ln -s /opt/ant/bin/ant /usr/bin/ant

Update bash profile:

echo 'export ANT_HOME=/opt/ant' >> /etc/profile.d/java.sh
echo 'export JAVA_HOME=/usr/lib/jvm/java' >> /etc/profile.d/java.sh
echo 'export PATH=$PATH:/opt/ant/bin' >> /etc/profile.d/java.sh
echo 'export CLASSPATH=.:$JAVA_HOME/lib/classes.zip' >> /etc/profile.d/java.sh
source /etc/profile.d/java.sh

Install Red5:

cd /opt
svn co http://red5.googlecode.com/svn/java/server/trunk red5
cd red5
ant prepare
ant dist

(Note: If you get an error about build.xml not existing, try instead downloading the red5 tarball and extracting it to the same location.  You can get the sources here).

Create an init script

By default you have to use red5’s inherent scripts to start/stop, which can be a bit annoying. Create a file called /etc/init.d/red5 and past in the following:

#!/bin/sh
# chkconfig: 2345 95 20
# description: Red5 flash media server
# processname: red5
PROG=red5
RED5_HOME=/opt/red5
DAEMON=$RED5_HOME/$PROG.sh
PIDFILE=/var/run/$PROG.pid
# Source function library
. /etc/rc.d/init.d/functions
[ -r /etc/sysconfig/red5 ] && . /etc/sysconfig/red5
RETVAL=0
case "$1" in
start)
    echo -n $"Starting $PROG: "
    cd $RED5_HOME
    $DAEMON >/dev/null 2>/dev/null &
    RETVAL=$?
    if [ $RETVAL -eq 0 ]; then
        echo $! > $PIDFILE
        touch /var/lock/subsys/$PROG
    fi
    [ $RETVAL -eq 0 ] && success $"$PROG startup" || failure $"$PROG startup"
    echo
    ;;
stop)
    echo -n $"Shutting down $PROG: "
    killproc -p $PIDFILE
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$PROG
    ;;
restart)
    $0 stop
    $0 start
    ;;
status)
    status $PROG -p $PIDFILE
    RETVAL=$?
    ;;
*)
    echo $"Usage: $0 {start|stop|restart|status}"
    RETVAL=1
esac
exit $RETVAL

*Note that WordPress has a strange way of outputting double quotes, so make sure you address those in the script!
Now, chmod 755 /etc/init.d/red5 and run:

chkconfig red5 on

This will run Red5 on startup. With the init script, you can now start, stop, and restart red5 as needed, ex:

service red5 restart

red5 should now run port 5080 and rtmp service on port 1935. You may need to open these ports in your server’s firewall.

Test:

http://hostname:5080/demos/port_tester.swf

Source: Adapted from http://www.sohailriaz.com/how-to-install-red5-server-on-centos-53/


6 Comments

  1. Vipin Reply

    Hi, I have installed Red5 v 0.9 successfully on my server (centos) but i can’t access the myhostname:5080 as you said. Pls help me

  2. kasim Reply

    OS Windows Server 2008
    Red5 0.9

    Server ip address is 192.168.148.128

    i connect it from 192.168.20.118

    Everything works fine. when i click on connect from oflaDemo it gives me following error.

    (5836) NetConnection.onStatus: level = error code = NetConnection.Connect.Failed

    the problem is it still shows rtmp://localhost/oflaDemo, and i think it should have shown 192.268.248.128 which is the server in this case.

    please help me .

Leave a Reply

Your email address will not be published. Required fields are marked *

Log in