Red5 Flash media server development: How to install and configure ?

Red5 Flash media server development: How to install and configure ?

What is red5 server ?

Red5 is an Open Source Flash Server written in Java that supports:

  • Streaming Audio/Video (FLV and MP3)
  • Recording Client Streams (FLV only)
  • Shared Objects
  • Live Stream Publishing
  • Remoting (AMF)
  • This is an amazing application for developing flash. even though its installation is not in a straight way. So this document will help you to setup a red5 server with a cool startup script to start and stop installations.

    IMP: This procedure istested in RHEL , Fedora , Centos5 cpanel servers with red5 version 0.7.0. So I hope it will work in most distributions. But the startup script will not work in debian flavors. I don’t have so much time to buy a server and install debian for testing. May be in near future I can do that.

    Packages required for installation.

    • Jdk 1.5 , J2ee.jar
    • Apache-ant
    • svn client ( for downloading the svn packages of red5 )
    • Lates red5 svn trunc distribution ( Please don’t use the tar distribution of red5, because some jar mirror are missing during make )
    • 1) Installing Jdk and J2ee.jar

      Please download and install the jdk and j2ee.jar from a java mirror. Or just copy paste the following links.

      # cd /usr/local/src
      # wget http://downloads.sherin.co.in/java/jdk-1_5_0-linux-i586.bin
      # chmod 755 jdk-1_5_0-linux-i586.bin
      #./jdk-1_5_0-linux-i586.bin
      # mv jdk1.5.0/ /usr/local/
      # ln -s /usr/local/jdk1.5.0/ /usr/local/jdk
      #wget http://downloads.sherin.co.in/java/j2ee.jar
      # mv j2ee.jar /usr/local/jdk/lib/

      Now the installation of java components finished.

      2) Installing Apache Ant

      Please go to http://ant.apache.org/bindownload.cgi and download latest apache-ant distribution, or copy paste the following lines.

      # cd /usr/local/src/
      # wget http://downloads.sherin.co.in/red5/apache-ant-1.7.1-bin.tar.gz
      # tar -xzf apache-ant-1.7.1-bin.tar.gz
      # mv apache-ant-1.7.1 /opt/
      # ln -s /opt/apache-ant-1.7.1 /opt/ant

      3) Set the PATHS

      This is very important. If you are skipping this step then you are breaking the installation. So very important to set the paths .

      Do the following commands,

      # export JAVA_HOME=/usr/local/jdk
      # export PATH=$JAVA_HOME/bin:$PATH
      # export CLASSPATH=.:$JAVA_HOME/lib/classes.zip
      # export PATH=”$PATH:/usr/local/bin:/usr/X11R6/bin:/opt/ant/bin”
      # export ANT_HOME=/opt/ant

      Now open the file /etc/bashrc and insert the above lines ( without # ) at the bottom of the script, because for the future working you need these environment variables. Otherwise you may need to set the above variables again and again during every login time. So It is very important to set the above lines in /etc/bashrc , got it !

      4) Installing svn

      In general all distributions have its own subversion packages. In Centos/RHEL/Fedora you can use “yum” to install svn client.
      # yum install subversion
      Or download the source of svn and install it.

      5) Installing red5

      Now proceed with following steps to install red5 FMS. Please use only SVN TRUNC distributions.

      # cd /opt/
      # svn co http://svn1.cvsdude.com/osflash/red5/java/server/trunk red5
      # cd red5/
      # make

      Now we have build the red5 server. So the next step is configuring start up scripts. This script is very use full to start/stop red5 server. unfortunately red5 distributions not providing it. So I wrote this small script. This script is using the normal start/stop scripts from the folder /opt/red5/dist/.

      6) Creating init start-up script /etc/init.d/red5

      Now create a file with name /etc/init.d/red5 . Please copy paste the following code to /etc/init.d/red5.

      #==========Start init script ==========

      #!/bin/sh # red5 # chkconfig: 2345 95 55 # description: red5 server startup script
      
      # Source function library. if [ -f /etc/init.d/functions ]; then . /etc/init.d/functions elif [ -f /etc/rc.d/init.d/functions ]; then . /etc/rc.d/init.d/functions else echo "Could not find functions file, your system may be broken" exit 1 fi
      
      # Source networking configuration. if [ -f "/etc/sysconfig/network" ] ; then . /etc/sysconfig/network fi
      
      # Check that networking is up. [ ${NETWORKING} = "no" ] && exit 0
      
      # See how we were called. case "$1" in start) # Start daemons. echo -n "Starting red5: " cd /opt/red5/dist/; sh red5.sh 2 >/dev/null & echo_success echo touch /var/lock/subsys/red5 ;; stop) # Stop daemons. echo -n "Shutting down red5: " cd /opt/red5/dist/; sh red5-shutdown.sh 2 >/dev/null echo_success echo rm -f /var/lock/subsys/red5 ;; *) echo "Usage: red5 {start|stop}" exit 1 esac
      
      exit 0 

      #=============End of init==============

      PS : You can download it from http://script.sherin.in/red5.sh . if so move red5.sh to /etc/init.d/red5 .

      Now we have created the init sript. chmod this script for getting execute permission .

      # chmod 755 /etc/init.d/red5

      Now start/stop the red5 server as follows

      # /etc/init.d/red5 start
      # /etc/init.d/red5 stop

      7) Testing the installation

      First you need to start your red5 installation using he following command,

      # /etc/init.d/red5 start

      Now open your web browser and type the following url

      http://<server ip adress : 5080/

      where , “server ip address” is the IP of your server.

      TIP: if you need to automatically start the service during system start up, please add “” /etc/init.d/red5 start” line to /etc/rc.local

      So this is all about red5 server installations.