How To Install RED5 Server on Centos 5.3

In this how to i will describe how to install RED5 server on Centos 5.3. This how to can be used to install RED5 server on Centos 4 and Fedora 8 – 11 as well. RED5 is open source flash server written in java supports streaming audio/video, recording client streams, shared objects, live stream publishing etc.

1) Download and 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

2) Download and Install Ant & Ivy (Apache Project)

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://mirrors.isu.net.sa/pub/apache//ant/binaries/apache-ant-1.8.2-bin.tar.bz2
tar jxvf apache-ant-1.8.2-bin.tar.bz2
mv apache-ant-1.8.2 /usr/local/ant

cd /usr/src
svn co https://svn.apache.org/repos/asf/ant/ivy/core/trunk ivy
cd ivy
ant jar
cp build/artifact/jars/ivy.jar /usr/local/ant/lib/

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

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

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.

5) Init Script

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

vi /etc/init.d/red5

download https://www.sohailriaz.com/downloads/red5.txt and copy / paste code in it. The init script code also be viewed 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

Enable executable permission

chmod +x /etc/init.d/red5

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.

6) Test

Now test the RED5 installation by opening following URL in browser

http://yourip:5080/

you will see red5 page like this

red5_11

and demos can be find here.

http://yourip:5080/demos/

red5_21

You can use simple port tester tool that determines which ports the Flash Player is able to connect through to the Red5 server. Put your server address or IP in HOST when using port tester. You should get SUCCESS on RTMP or port 1935. If not please check your firewall.

http://yourip:5080/demos/port_tester.html

red5_3

7) ISSUE

When you run ./red5.sh, it will show you Installer service created. Thats mean everything runs fine and red5 server is up. But if you went to port_tester.swf using demos above or your application shows connections FAILS, this is an issue of RTMPT and RTMPTS. You can see it by running

/usr/local/red5/red5.sh

output trancated

[INFO] [main] org.red5.server.tomcat.TomcatLoader – RTMPT server bean was not found
[INFO] [main] org.red5.server.tomcat.TomcatLoader – RTMPS server bean was not found

output truncated

If you see this you have to uncomment the RTMPT and RTMPTS TomcatLoader in/usr/local/red5/conf/red5-core.xml

vi /usr/local/red5/conf/red5-core.xml

Search for a lines

<!– RTMPT –>
<!–
<bean id=”rtmpt.server” class=”org.red5.server.net.rtmpt.TomcatRTMPTLoader” init-method=”init” lazy-init=”true”>

Remove the <!– from start of <bean and –> from end of </bean>

Same goes for RTMPS

<!– RTMPS –>
<!–
<bean id=”rtmps.server” class=”org.red5.server.net.rtmps.TomcatRTMPSLoader” init-method=”init” lazy-init=”true”>

Remove the <!– from start of <bean and –> from end of </bean>

Restart the red5 services and connection fails problem will be fixed.

If you any question please use comments.

Related Posts

482 thoughts on “How To Install RED5 Server on Centos 5.3

  1. I have followed all instructions listed here step by step and when I try to start red5 I get Permission Denied

  2. I learn quickly but I am def a newbie when it comes to dedicated servers –

    @Ralph

    CentOS CentOS 5.5-64

    SuperMicro X8DTU-F Intel Xeon QuadCore DualProc SAS/SATA [2Proc]

    @ Sohail

    I am just learning SSH and I am using PUTTY – only know a few commands so if you can tell me who to do what you are suggesting that would save me time from searching for it.

    Thanks for all your help.

  3. OK I

    CHMOD 755 /etc/init.d/red5

    CHMOD 755 /usr/local/red5/red5.sh

    then I entered /etc/init.d/red5 start

    and now I am getting the following:

    /etc/init.d/red5: line 49: stop: command not found
    /etc/init.d/red5: line 49: restart: command not found
    /etc/init.d/red5: line 49: status}.: command not found

  4. I had this problem. If I remember correctly, it was a typo in the red5 script.

    nano /etc/init.d/red5

    correct the lines….

  5. OK – now that I have edited the file as suggested by Mark – Red5 starts

    Now when I do the http://ipadd:5080/demos/port_tester.html

    I get FAILED all the way through

    I have looked through this document and followed the steps to uncomment the RTMPT and RTMPS but they were not commented.

    So now what?

  6. All up and running – Thank you to all who has helped me with this.

    @Dean – your step by step was right on man – thanks.

  7. @Randy… Glad they worked for you.. I should write this up on my own site but dont know if I could handle the 100+ questions per day.. lol…

  8. my red5 installation stuck on following stage
    kindly please help me
    how many time it will take to install?

    ” [INFO] [main] org.red5.server.tomcat.TomcatLoader – Dedicated RTMPS server configuration was not specified Bootstrap complete [INFO] [Launcher:/] org.springframework.beans.factory.config.PropertyPlaceholderConfigurer – Loading properties file from ServletContext resource [/WEB-INF/red5-web.properties] [INFO] [Launcher:/] org.springframework.beans.factory.support.DefaultListableBeanFactory – Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1535a58: defining beans [placeholderConfig,web.context,web.scope]; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory@db3331 [INFO] [Launcher:/installer] org.springframework.beans.factory.config.PropertyPlaceholderConfigurer – Loading properties file from ServletContext resource [/WEB-INF/red5-web.properties] [INFO] [Launcher:/installer] org.springframework.beans.factory.support.DefaultListableBeanFactory – Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@177fa9a: defining beans [placeholderConfig,web.context,web.scope,web.handler,installer.service]; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory@db3331 [INFO] [Launcher:/installer] org.red5.server.service.Installer – Installer service created”

  9. @Ali: Delete directory /usr/local/red5 and delete /etc/init.d/red5 file. This will remove red5 completely. Be remember to stop red5 service before deleting it.
    ————
    Regards,

  10. When I try to start Red 5, am greeted by this:

    /etc/init.d/red5: line 42: stop: command not found
    /etc/init.d/red5: line 42: status}.: command not found
    /etc/init.d/red5: line 42: restart: command not found

    I don’t know how to fix this…

  11. @Vincent,

    As Mark said, sift through the older comments. Almost every problem with red5 installation has been answered here.

    I have even written a different method of installing red5 and posted it here.

  12. @ Vincent,

    Mate if none of these turiorials work for you then you are simply doing something wrong. It works for me and many others. I am using the latest Centos and Red5 (have used older versions too) and it works just fine.

  13. Sir, I did everything you said. My Red5 server is up but I have the same problem with RTMPT and RTPMS. In my file there are no lines you mentioned. my file is

    <!– Enable this if you want to allow global scope connections

    –>

    <!– You can now add additional ports and ip addresses

    –>


    <!–

    –>

    –>

    Please give me the reply how can I enable the RTMPT and RTMPS. Waiting from ur side.

    Regards,
    Salman

  14. Hello,
    thank you so much for the post.

    Does anyone know why i can not see the red5 admin?
    I recently installed the 1.0 and i can not access the admin at all.
    I can see the demo admin but i am not sure if that is the same. But even if so, I have not assigned username and password. So, so how can i access?

    thank you

  15. I am trying the :
    # ant prepare
    and i get the following error:

    Error occurred during initialization of VM
    Could not reserve enough space for object heap
    Could not create the Java virtual machine.

    any idea on that please?

    thank you

  16. I got throughout ant prepare but i get an error with and dist

    Hello,
    I keep on getting an issue after running the “ant dist”
    ________________________________________

    [ivy:retrieve] :: retrieving :: red5#server
    [ivy:retrieve] confs: [java6]
    [ivy:retrieve] 59 artifacts copied, 0 already retrieved (38469kB/171ms)
    [javac] Compiling 525 source files to /usr/local/red5/bin

    BUILD FAILED
    /usr/local/red5/build.xml:225: The following error occurred while executing this line:
    /usr/local/red5/build.xml:246: Error running /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/bin/javac compiler

    Total time: 2 seconds
    ________________________________________

    Any Idea on how i can fix that ?

  17. I never got that far i made a java mess.
    after I tried to intall java a few times

    export JAVA_HOME=/usr/lib/jvm/java

    error not configured correctly

    I think bash error coming from here:

    echo ‘export JAVA_HOME=/usr/lib/jvm/java’ >> /etc/bashrc

    How would I remove all instances of java to start from scratch? Centos 5.6 64bit

    Funny thing is this is not the first time I have used you script. It has always gonna flawlessly in the past.

  18. When I login ssh this is what i get:

    -bash: .export: command not found
    -bash: .export: command not found
    -bash: .export: command not found
    -bash: .export: command not found
    -bash: .export: command not found
    -bash: .export: command not found
    -bash: .export: command not found
    -bash: .export: command not found

  19. @John: Do the following

    vi /etc/bashrc

    at end of file you will find all these export commands

    delete all of them and leave three lines like this.

    ANT_HOME=/usr/local/ant
    JAVA_HOME=/usr/lib/jvm/java
    PATH=$PATH:/usr/local/ant/bin

    Save the file. It will make ant and java environment and will not give any error.
    ——————
    Regards,

  20. Error: JAVA_HOME is not defined correctly.
    We cannot execute /usr/local/jdk/bin/java

    I think there is a issue with ant install?

    ant build, test, install give same error

    ANT_HOME=/usr/local/ant
    JAVA_HOME=/usr/lib/jvm/java
    PATH=$PATH:/usr/local/ant/bin
    Have just these three line before end

    with #sudo /usr/sbin/alternatives –config java

    Selection Command
    ———————————————–
    1 /opt/jdk1.6.0_07/bin/java
    *+ 2 /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java

    Thank you for your time
    vi /etc/bashrc

  21. @John: OK you have two version of java installed. You can use one of them. The steps mine is only using openjdk.

    You can do following

    JAVA_HOME=/opt/jdk1.6.0_07/

    OR

    JAVA_HOME=/usr/lib/jvm/jre-1.6.0-openjdk.x86_64/

    change this in your /etc/bashrc file.
    —————-
    Regards,

  22. /usr/local/red5/red5.sh
    Running on Linux
    Starting Red5
    Exception in thread “main” java.lang.NoClassDefFoundError: org/red5/server/Bootstrap
    Caused by: java.lang.ClassNotFoundException: org.red5.server.Bootstrap
    at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:319)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:264)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:332)
    Could not find the main class: org.red5.server.Bootstrap. Program will exit.
    How i can fix it.

  23. I installed red5 but the ports tester says everything fails, I changed localhost to the ip address of my server, and went to /usr/local/red5/conf/red5-core.xml but lines to uncomment not even one that says Tomcat. Any suggestions?

    Thanks

  24. @ Octavio,

    This has been discussed many many mant times here. Read through all the posts. Some where, and may of times, it has been explained that you have to open the ports for red5 in your firewall.

  25. Please can someone posts a really working red5-core.xml for version 1.0RC1. Port tester fails every time. Thank you

  26. Just wanted to say thanks, your instructions worked perfectly! I have successfully set up on CentOS 5.5 and once enabling the port from iptables everything works perfectly. Thanks again!

  27. Hi, when i try to start with command /etc/init.d/red5 start
    i have a response: red5 startup: command not found. What is the problem?

  28. I’ve done. Starting red5: OK. But when i try command status, response is: red5 dead but pid file exists. End i can’t stop red5

Leave a Reply

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