How to install Red5 on Cent Os 5.4

Red5 is open source flash server written in java supports streaming audio/video, recording client streams, shared objects, live stream publishing etc. Here I will describe in details how you can install Red5 on your CentOS. For this you will also need to install Java and Apache Ant.

Step 1. Install Java

RED5 server depends on Java. CentOS 5.3 comes with OpenJDK 1.6 and install it using yum.

yum -y install java-1.6.0-openjdk java-1.6.0-openjdk-devel

Step 2. Install Ant

Ant will need to compile RED5 server code. Ant comes in binary form, so just download and install it in /usr/local directory.

cd /usr/src
wget http://opensource.become.com/apache/ant/binaries/apache-ant-1.7.1-bin.tar.gz
tar zxvf apache-ant-1.7.1-bin.tar.gz
mv apache-ant-1.7.1/ /usr/local/ant

Step 3. Export Variables for Ant and Java

export ANT_HOME=/usr/local/ant
export JAVA_HOME=/usr/lib/jvm/java
export PATH=$PATH:/usr/local/ant/bin
export CLASSPATH=.:$JAVA_HOME/lib/classes.zip

Also export these variables in /etc/bashrc to become available for every user login or for any terminal opens.

echo ‘export ANT_HOME=/usr/local/ant’ >> /etc/bashrc
echo ‘export JAVA_HOME=/usr/lib/jvm/java’ >> /etc/bashrc
echo ‘export PATH=$PATH:/usr/local/ant/bin’ >> /etc/bashrc
echo ‘export CLASSPATH=.:$JAVA_HOME/lib/classes.zip’ >> /etc/bashrc

Step 4. Download and Install RED5 Server

Here the latest version available for RED5 is 0.7 on site but download from google code using svn as the tarball of 0.7 on site is missing some of the files.

cd /usr/src
svn checkout http://red5.googlecode.com/svn/java/server/trunk/ red5
mv red5 /usr/local/
cd /usr/local/red5
ant prepare
ant dist

you will see a ton of lines, but you should get at last

BUILD SUCCESSFUL

that’s mean its install and now copy the conf directory from dist/ and test the red5 installation.

cp -r dist/conf .
./red5.sh

If it shows Installer service created in the last then everything is fine here, press ctrl+c and move to next step to create init script.

Step 5. Init Script

Now we will create init script for red5 to start, stop and restart easily.

vi /etc/init.d/red5

The init script code is below.

#!/bin/sh
# For RedHat and cousins:
# chkconfig: 2345 85 85
# description: Red5 flash streaming server
# processname: red5

PROG=red5
RED5_HOME=/usr/local/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

Now start the service

/etc/init.d/red5 start

check status

/etc/init.d/red5 status
red5 (pid XXXXX) is running…

again you can do stop, restart.

Step 6. Test

Now test the RED5 installation by opening following URL in browser

http://yourip:5080/

You will see Red5 test page.

About Saifur

A passionate software engineer, having several years of experiences in different area of software industry in Europe and Asia loves music, playing soccer, traveling new places, researching on new technologies such as programming languages, frameworks, software architectures and different project management practices.

, , , ,

23 Responses to How to install Red5 on Cent Os 5.4

  1. Anandpatel December 18, 2009 at 8:05 pm #

    Hey MAte

    I followed the steps but when i am typing ant prepare and ant dist , its saying command not found.

    Kindly help me ASAP if possible,

    Regards,
    Anand

  2. Saifur December 18, 2009 at 8:07 pm #

    Please recheck whether you have followed step 2 & 3 properly.

  3. alieca December 21, 2009 at 9:40 pm #

    Is it possible to install it without root access ?

  4. Matt December 22, 2009 at 10:22 pm #

    Awesome – thanks

    Had to replace some quotes ” in the init script but other that than brilliant.

  5. Ronny December 25, 2009 at 12:26 am #

    Hi, great tutorial!
    Everything went without a lot of hickups until I got to the init script. When I run it, I get the following error:

    [root@centos red5]# /etc/init.d/red5 start
    /etc/init.d/red5: line 43: stop: command not found
    /etc/init.d/red5: line 43: restart: command not found
    /etc/init.d/red5: line 43: status}”: command not found

    I’m not familiar with bash/linux at all, so I can’t really figure out what I did wrong. I just copied the script you gave into the vi editos and saved it. I verified if it was saved and it is.

    I had to chmod 755 it before I could run it though. But this is where i’m stuck right now.

    Any piece of advice?
    Thanks again, you’re really helping me out :)

  6. Davor December 28, 2009 at 7:05 am #

    Same problem here:

    [root@centos red5]# /etc/init.d/red5 start
    /etc/init.d/red5: line 43: stop: command not found
    /etc/init.d/red5: line 43: restart: command not found
    /etc/init.d/red5: line 43: status}”: command not found

    Please help!

  7. camdebuck January 13, 2010 at 5:54 am #

    Problem is most likely with the case statement:

    make sure it read: case \"$1\" in
    (ie, case doublequote$1doublequote

    I had an issue where it put a . instead of the doublequote and was causing problems when copying and pasting from the website

  8. camdebuck January 13, 2010 at 6:06 am #

    If you have a firewall turned on, make sure you add port 5080 to your firewall (do a search for adding a port to your firewall).

    If you don’t this, http://yourip:5080/ will not work.

  9. camdebuck January 13, 2010 at 6:14 am #

    You will need to add port 1935 for RTMP

  10. Paul Wood February 4, 2010 at 6:21 am #

    Ive gotten through everything except when I try to start the server with \"/etc/init.d/red5 start\" either permission is denied or command is not found. Also i get these -bash: commands not found when i login through ssh.

    If anyone can help me that would be super sweet.

    What I see in the terminal:

    Last login: Wed Feb 3 23:48:15 2010 from c-24-9-203-1.hsd1.co.comcast.net
    -bash: ‘export: command not found
    -bash: ‘export: command not found
    -bash: ‘export: command not found
    -bash: ‘export: command not found
    [root@BeheardCentOS2 ~]# /etc/init.d/red5 start
    -bash: /etc/init.d/red5: Permission denied
    [root@BeheardCentOS2 ~]# sudo /etc/init.d/red5 start
    sudo: /etc/init.d/red5: command not found

  11. TheObserver March 4, 2010 at 2:51 pm #

    Hi Paul wood,

    you might want to try this solutions, I google searched it for you

    http://blog.mohdazam.com/lastlogin-information-bash-error

    Your problem might be solved, last time a friend of mines also experiencing this problem, and use that solutions..it is worked!

  12. Adrian March 26, 2010 at 4:13 am #

    I am getting this error when starting the server:

    [root@cl-t029-292cl ~]# /etc/init.d/red5 start
    -bash: /etc/init.d/red5: Permission denied

    I looked at TheObserver’s solution but that doesn’t work.

    Anyone can help.

  13. Adrian March 26, 2010 at 4:50 am #

    I figured it out.

    Had to change the permission of the /etc/init.d/red5 file to 755.

  14. nithin April 2, 2010 at 6:50 pm #

    i am getting svn command not found

  15. Shawn Hyde April 15, 2010 at 3:25 pm #

    Those of you getting the errors, open:
    /etc/init.d/red5
    with a text editor and replace all of the quotes then, do:
    /etc/init.d/red5 start

  16. JackCR00 April 24, 2010 at 5:27 am #

    nithin

    yum install subversion

  17. Jack May 5, 2010 at 10:12 pm #

    A good RED5 installation tutorial, would like to share
    http://askmeflash.com/tutorial/7/red5-installation-and-setup-how-to

  18. Tofan May 11, 2010 at 8:20 am #

    Thanks for tutor …

    I’am using CentOS 5.4
    and my red5 server is running quit well

    But I have big trouble to integrating php in red5 server.

    I want to running live streaming php standalone version from videowhisper, but it’s not working yet.

    Can you give me some guidance, to make php working on red5?

    Thanks for advance

  19. Bond August 2, 2010 at 4:42 pm #

    Well if you people are getting problem in starting Red5 by above method.Go to /opt/red5/dist/red5.sh
    and then execute this script and not the script that comes
    in /opt/red5/red5.sh

  20. swapnil_jaiswal August 9, 2010 at 1:35 pm #

    hey for the bash errors ;
    copy paste the init script as is then
    replace the line
    case “$1? in
    with
    case “$1″ in

    this worked for :)

    and thanks a lot
    Saifur Rahman

  21. Mike Todd September 13, 2010 at 10:41 pm #

    As a note, this tutorial doesn’t quite work with Red5 version 0.9. The latest version does not come with a Tomcat server built-in, so you have to do that yourself. You also need to edit the config file to make Red5 bind to the correct IP address, which is not mentioned in this guide.

    So, here are some more instructions to bring this tutorial up to date:

    * Edit red5/conf/red5.properties file, and anywhere you see the IP 0.0.0.0 replace it with your server’s actual IP address.
    – You can find this IP by executing this command: /sbin/ifconfig eth0| grep ‘inet addr:’ and use the IP address listed directly after inet addr:
    * Create directory red5/plugins
    * Go to http://www.red5.org/wiki/AppServer/JEEContainerPlugins, get pre-compiled Tomcat JAR
    * Look inside of Tomcat JAR, extract the jee-container.xml file, replace red5/conf/jee-container.xml file with that.
    * Go to http://code.google.com/p/red5/source/browse/#svn/repository/tomcat, save the latest version of each file there to red5/plugins
    – As of today (September 13, 2010), this includes 6.0.26 of Catalina and Jasper and Tomcat-Coyote, and 6.0.20 of Tomcat-dbcp, Tomcat-juli, and Tomcat-juli-adapters

  22. Kevin Lee October 1, 2010 at 6:05 am #

    I have just buy a VPS , but I am trying to install but I can not. Who help me ? :( (

  23. blero November 25, 2010 at 11:04 am #

    how to save the script ?

Leave a Reply


*