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. Thanks Sohail
    I need some one who is experianced to configure the last part ofthis any one please contact me via yahoo id=maheeboo

    and google chat is mdpereracom

    I am online now

  2. I got stuck at step 5 too. I am a newbie to Linue and just got my dedicated server and trying to install red5.

    When I do vi /etc/init.d/red5 it opened up vi editor, so I copy and paste your code in I lost right there. I dónt know how to use VỊ I used Pico because it has a menu at the bottom, but for Vi, I don’t know the command to save the file.

    Then I managed to save the file and I run /etc/init.d/red5 start I got Permission denied

    root@server1 [/etc/init.d]# /etc/init.d/red5 start
    -bash: /etc/init.d/red5: Permission denied

    Can you help me?

  3. @Shail,

    Thanks for your help on that issue and I followed your guide I got the red5 started. However, when I try to view the demos to see if Red5 is working or not, the web browser is not able to connect to the demo page. I go to http://xxx.xxx.xxx:5080/demos and it shown “page not found or connection failure”

    Can you please help?

    Thanks

  4. @Michael: First check red5 is running or not by issuing following command

    /etc/init.d/red5 status

    If its shows running then check your firewall is enabled and if enabled check your firewall should accept connections for port 5080 and 1935

    Regards,

  5. Sohail,

    Thansk for putting your time to help me.

    I ran /etc/init.d/red5 status

    Then I got this message:

    root@server1 [/]# /etc/init.d/red5 status
    red5 dead but pid file exists

    What does it mean?

  6. @Michael: This is because the java class cannot found for red5, kindly do the following to fix this
    ——————-
    1) Update your /etc/init.d/red5 script with from my blog again as i put the right code in it. Its updated.
    ——————
    2) if you want to check the red5.sh, do like this
    cd /usr/local/red5
    ./red5
    —————-
    it will run fine then
    ————
    Regards,

  7. Yeah, it is working. Thank you so very much. You saved me $50 for not hiring a company to do it

    Thanks

  8. Thanks Sohail
    Excuse me for my bad English.
    I’m running demos, but when I connect to server I see

    (7645) connected?: true
    (7658) NetConnection.onStatus:
    description = No scope “oflaDemo” on this server.
    code = NetConnection.Connect.InvalidApp
    level = error

    (7658) NetConnection.onStatus:
    level = status
    code = NetConnection.Connect.Closed

    And no connection.
    Please help me!!!!

  9. No, I don’t now what is demos installer.
    I think that port tester working correctly.

    Best Regards

  10. hi pal ,
    Thank You….
    but i got stucked with an error…
    can u pls help me out??

    error is as follows:

    red5/webapps/root/demos/port_tester.swf
    A red5/webapps/root/demos/bwcheck.html
    A red5/webapps/root/demos/index.html
    A red5/webapps/root/demos/DevNotes_NetConnection.swf
    A red5/webapps/root/demos/echo_test.swf
    A red5/webapps/root/demos/simpleSubscriber.swf
    A red5/webapps/root/demos/port_tester.html
    A red5/webapps/root/demos/BallControl.html
    Checked out external at revision 3867.

    Checked out revision 3867.
    [root@angels src]# mv red5 /usr/local/
    [root@angels src]# cd /usr/local/red5
    [root@angels red5]# ant prepare
    Buildfile: build.xml

    BUILD FAILED
    /usr/local/red5/build.xml:5: Class org.apache.tools.ant.taskdefs.ConditionTask doesn’t support the nested “antversion” element.

    Total time: 0 seconds
    [root@angels red5]# ant dist
    Buildfile: build.xml

    BUILD FAILED
    /usr/local/red5/build.xml:5: Class org.apache.tools.ant.taskdefs.ConditionTask doesn’t support the nested “antversion” element.

    Total time: 0 seconds

    ????

  11. yes man, i found the version is 1.6.5 . u r ryt ..
    but i performed all steps as per ur documentation, but its not changing..
    so can u pls tel me how can i uninstall the previous version and install new???

    i tryed many times .. but the same result am getting..
    so can u pls help me more???
    THANKS in advance…

  12. hi sohail,
    thakyou..
    i removed ant and reinstalled ..
    and everything gone well..
    but at last a small error came

    /etc/init.d/red5 start
    /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

    can u pls help me here also….

    u r gr8 man.. super
    n very very thankssss

  13. @chettai: OK the issue is in the red5 script. Kindly open script file
    vi /etc/init.d/red5
    and delete and re-enter double quotes ”
    —-
    and save then start
    —-
    Regards,

  14. YES, man..
    done…
    thankyou very much frnd…
    so can u pls explain me how can i setup the server configuration also??
    i mean i want to stream my webcam output to red5 server n want to put a live show in site..
    can u pls help me here also????

  15. Thanks a lot brother. I was able to install red5 with hardly any effort by following your simple and clear instructions.

    Just one thing for others. The double quotes in the script(”) need to be replaced by the double quotes on the key board (“). They are not the same.

  16. @Alfie Punnoose: Yes i am trying to figure it out, it may be in the theme which replace the double quotes to some other format.
    ———
    Regards,

  17. hi,
    1st THANKYOU…
    my red5 get worked …
    but now my jw player i need to configure..
    i saw my stream from LongTail Video site.. and copied the code, and just placed in my site..
    but its player iteslf not showing anything in my site…
    can u pls help me?

    does the code need anything special ?? i just pasted code in my page only, does it hav any problem???

    i think u can troubleshoot …..
    pls try…

  18. on step 4
    when i run
    ant dist

    I get
    BUILD FAILED
    /usr/local/red5/build.xml:220: The following error occurred while executing this line:
    /usr/local/red5/build.xml:241: Error running /usr/lib/jvm/java-1.6.0-openjdk-1.6 .0.0/bin/javac compiler

  19. Hey Sohail,
    U become my friend u know how ? For the past two days i’been scanning line by line of your web page to set up red5 running.At last i could see everything running till the 5th step.Last step 6 is not working fr me but i beleive this may not be in ur scope.Could be a system port is engaged or so.But i must thank you my friend .
    Anyone happend to read this please understand Sohail is
    ========================================= clearly explaine everything.But one thing BLINDLY DON’T COPY &PASTE THE CODE SEE THE (” ,’ ) INVERTED COMAS THERE IN YOUR PASTED CONTENT.
    Thanks Again

  20. hi frends..i installed red5 on ly linux….but when i typr the ip address in the browser,it is showing me page lode error..the internet is alsio connected properly..so can u plzzzz tell me wr the actual problem is

  21. so after that can i now install rtmp server on my linux machine….plz giv me some sites wr can i get the correct steps
    for installation on linux(Fedora 10)

  22. hi frend…when i try to install JDK on my linux(fedora).its showing like
    [root@v2-035 v2soft]# yum -y install java-1.6.0-openjdk.java-1.6.openjdk-devel
    Loaded plugins: refresh-packagekit
    adobe-linux-i386 | 951 B 00:00
    fedora | 2.8 kB 00:00
    rpmfusion-free | 2.7 kB 00:00
    rpmfusion-free-updates | 2.8 kB 00:00
    updates | 3.4 kB 00:00
    updates/primary_db | 4.6 MB 01:46
    Setting up Install Process
    No package java-1.6.0-openjdk.java-1.6.openjdk-devel available.
    Nothing to do
    [root@v2-035 v2soft]#
    so plzzz help me ….in this

  23. @ramu:
    1)First check your firewall, you should have open port 1935 and port 5080.
    2) You given the wrong command in java installation.
    use this
    ———–
    yum -y install java-1.6.0-openjdk java-1.6.0-openjdk-devel
    ———–
    these are two packages and you put . (dot) and make them one package.
    ———
    Regards,

  24. I have installed according to the directions, status shows ok, netstat appears to be listening on port 5080, have talked to hostgator to open the port, still not connecting to it. Everything appears ok to me except for the fact that it is not working, help desperately needed, any ideas, can provide any docs needed.
    Thanks in advance,
    Reuben

  25. Hello Sohail,
    I ran /etc/init.d/red5 status
    got message red5 dead but pid file exists

    then ran /usr/local/red5/red5.sh got below messages
    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:323)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:336)

    Used the /etc/init.d/red5 script as shown in the above comments

  26. First of all, thank you for your clear and up to date explanation how to install Red5.
    Now I’m stuck on the 3rd rule of step 4.
    After the svn trunk download you say I have to type “red5” (without quotes)
    At that point i got the error: -bash: red5: command not found
    I guess I misunderstand something.
    Can you pls clear this out for me?

    It’s funny, this is the 4th or 5th time I try to install red5. And every tuto so far had a different way of installing Red5 :p

  27. Thank you, thank you, thank you, thank you, THANK you, thank you… 2 days it took me, but your How To was precise and it got the job done. Thanks.

  28. Also, those like me who have tried numerous times and failed, step 2, last line do [ rm /usr/local/ant/* -fr && mv apache-ant-1.7.1/* /usr/local/ant ] instead, just to clear out any old, outdated, corrupt versions of Ant you may have tried to install.

  29. thanks, I thought already so, and tried it. But I didn’t mentioned there was a spacebar between de url and red5 🙂
    It’s running now, only de port tester gives all fails. Also after de rtmp and rtmps modification.
    But I will figure it out later 🙂
    Thanks again for your help!

  30. Hi,

    I had the same issues like the others, now its working. I also touched the rtmp and rtmps modification, but now I cant install the Demos. Its just like a 404 error. With the Port tester it says that it cant connect to any port. The rest is working fine and Im also able to access the Port tester. Could you please give me a tip how to fix it?

    Thank you.

    Kind Regards

    Markus

  31. Ive found it, I rebooted the server and I saw comments about the environment variables. Seems like they are not working. Could you please tell us where the environment variables should be set? We use CentOS 5.4 with csh
    Thanks so much.

    Kind Regards

    Markus

  32. @Markus: I assume the default shell i.e bash so i used /etc/bashrc for all enteries.
    For csh you have to use /etc/csh.cshrc for all environment variables. I am writing below entries for csh.
    ======================
    setenv ANT_HOME /usr/local/ant
    setenv JAVA_HOME /usr/lib/jvm/java
    setenv PATH $PATH:/usr/local/ant/bin
    setenv CLASSPATH .:$JAVA_HOME/lib/classes.zip
    =======================
    echo ‘setenv ANT_HOME /usr/local/ant’ >> /etc/csh.cshrc
    echo ‘setenv JAVA_HOME /usr/lib/jvm/java’ >> /etc/csh.cshrc
    echo ‘setenv PATH $PATH:/usr/local/ant/bin’ >> /etc/csh.cshrc
    echo ‘setenv CLASSPATH .:$JAVA_HOME/lib/classes.zip’ >> /etc/csh.cshrc
    =========================
    Regards,

  33. I got stuck at step 5. I am a new to Linux and just got my vps server and trying to install red5.

    I ran /etc/init.d/red5 status

    Then I got this message:

    root@server1 [/]# /etc/init.d/red5 status
    red5 dead but pid file exists

    Then when I run /usr/local/red5/red5.sh I got this message:

    Running on Linux
    Unable to locate Java. Please set JAVA_HOME environment variable.

    Can you please help?

  34. Thanks, that helped. Also you should set the links to /etc/rc.d s so that the init script will be started and stopped automatically at system startup.
    @vigneshwari
    You need to verify that you Java home is set correct. Just type java -version and look if it works. If not you need to set the environment variables as shown in this tutorial.

    Kind Regards
    Markus

  35. @Markus: Yes that init script is created for running at startup of the system.
    @vigneshawari: as markus says, you need to set the environment variables.
    ==========
    Regards,

  36. [root@vps3329 red5]# ant prepare
    Error: JAVA_HOME is not defined correctly.
    We cannot execute /usr/lib/jvm/java/bin/java

    what is the problem? before it was ok. after i used export variables as said by u. i got the error in ant. please help me

Leave a Reply

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