How to install RED5 on CentOS 5 – The complete guide

How to install RED5 on CentOS 5 – The complete guide


About 18 months ago I got my first VPS and figured out how to install RED5, the free open-source alternative to Adobe’s Flash Media Server. It’s a great alternative and the price (0.00 $) is just right. A few weeks ago I decided to upgrade my VPS plan at Vexxhost to a cloud server which meant I had to install everything all over again. Including RED5. I then decided to write a tutorial that includes all the steps needed to get RED5 up and running on your CentOS server.

It takes about 20-40 minutes depending on how much of a brainless copy-paster you are. And on that last note I’d like to add that I take no responsibility if anything goes wrong. These steps are the ones I followed and worked great for me. If for some obscure reason you do something that might mess up your server, I’m not going to take the heat for that. ;-)
So, how about it? Let’s get started, shall we?

Requirements

  1. SSH access to your VPS
  2. The root login to your server
  3. Basic knowledge of Java servers, SVN, etc
  4. A clue: If you don’t have a clue what you’re about to do here, it means you don’t need to do this and thus don’t need this tutorial.

Let’s go

Connect to your server over SSH. Make sure you are logged in as root. Everything from here on is assumed to be done over SSH with root privileges.

Prepare your server

JAVA

Red5 is a JAVA server. So you’ll need to have JAVA installed and running on your server. Check if you have JAVA installed by just using the following command:

java

If your server responds with information about the java command, you have java installed. Check to see if you have a valid version of JAVA running by using the following command:

java -version

The first line of the response should be something like “java version “1.6.0_20“. The really important bit here is 1.6.  If that is the case, you can skip this step. If it’s not, you’ll need to update Java. I can’t tell you how to do that. You’ll have to Google that. If you got a response similar to ‘command not found‘, you’ll need to install JAVA.
Installing JAVA on CentOS can be done using Yum. Like this:

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

Just sit back and watch the lines of text scroll by. This could take a while.
When the scrolling ends: tap yourself on the back. You just installed JAVA on your server. One step closer to success.

RED5 will run on JAVA. We will download the sources later on and then build the RED5 application ourselves. We will build the source using ANT.

ANT

First we need to check if  you have ANT installed. You can check this out by typing:

ant --help

If you get a manual page, you’re in the green. You can skip this step. If you don’t, you’ll have to install ANT. First off let’s change to another directory.

cd /usr/src

We need to download the latest ANT version. You can find the most recent versions here. The one provided in the following step is the most current one at the time of writing. Copy the url and enter it in the following command. This will download the file to your server in the directory /usr/src/.

wget http://opensource.become.com/apache/ant/binaries/apache-ant-1.8.2-bin.tar.gz

This is some kind of strange zip format. We need to uncompress this. (Remember to update the filename in the next step to the one you just downloaded in the previous step)

tar zxvf apache-ant-1.8.2-bin.tar.gz

So now we have all these files in the uncompressed folder, we need to move it to a save place… (Again keep in mind to change the foldername to your version of ANT you just downloaded, 2 steps ago)

mv apache-ant-1.8.2/ /usr/local/ant

So now we have JAVA installed, and ANT is in place. We need to make sure there are some environment variables set. These are global variables with paths to different binaries or applications. ANT and JAVA will need those. Copy and paste the following commands, one by one, BUT MAKE SURE the quotes are valid charachters. I noticed that copy/pasting from websites might mess this up. I suggest you take the time and replace them by hand before actually executing these commands.
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
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

All set? Good!
Okay, now ANT and JAVA should know enough about each other to get started. So now we essentially have everything to build the actual RED5 server except for the RED5 source. We will fetch the latest release from the SVN repository at Google Code. For that we will need SVN.

SVN

Let’s see if we have SVN installed:

svn --help

If you get the man pages, you’re free to skip this step. If you don’t: Let’s make it happen!

yum install subversion

If the SVN installation works right away: You’re done here. Skip to the next part. You might get an error like “Error: Missing Dependency: perl(URI) >= 1.17 is needed by package subversion“. That means you’re missing an RPM. Sucks, right? Let’s take care of this…

If your server is a 32bit machine, do the following:

wget ftp://ftp.pbone.net/mirror/archive.fedoraproject.org/fedora/linux/releases/7/Everything/i386/os/Fedora/perl-URI-1.35-3.noarch.rpm

If you’re on a 64bit machine:

wget ftp://ftp.pbone.net/mirror/archive.fedoraproject.org/fedora/linux/releases/7/Everything/x86_64/os/Fedora/perl-URI-1.35-3.noarch.rpm

Okay, so now you got that new RPM file. You’ll need to add this to the internal list of RPMs (I don’t even know what it’s called). That’ll take care of the error message mentioned above.

rpm -i perl-URI-1.35-3.noarch.rpm

You might get a warning after inserting this command. Don’t worry, I’ve seen it too and yet the world didn’t implode. So ignore that ;-) Try installing subversion again using the following command:

yum install subversion

It will ask you if it’s okay to download all this stuff. Of course it is. Type ‘y’ and hit enter to watch the server work away. You should end up with a ‘Complete!‘ message in the end. If you see the ‘Complete!‘ message: It’s okay to feel happy about yourself. You have now subversion running on your server. Or at least a client (from what I got). Getting closer!

Actually installing the RED5 server

Source

It’s finally time to get down to business: RED5. This is why we’re here!
Let’s make sure we’re in the right folder:

cd /usr/src

Let’s get the RED5 source:

svn checkout http://red5.googlecode.com/svn/java/server/trunk/ red5

This will fetch the complete Red5 source and save it in a new folder called, red5 (so in /usr/src/red5)
Now that we have the source, let’s move it to /usr/local/ using

mv red5 /usr/local/

Now let’s dive into the red5 source folder

cd /usr/local/red5

This is the folder where all the source files reside. From here on, we prepare and build the red5 source… This should be interesting. Run these commands one at a time:

ant prepare
ant dist

There’s a (I think the scientific term is) crapload of text going to scroll across the terminal window. Don’t freak out… Just enjoy the show. This is where you call your friends and make them watch the screen as the mass of text freakishly scrolls over your screen. This makes you look very smart. It also makes you look nerdy, but that’s okay. You kind of are… You _ARE_ in fact building a RED5 server… Ohwell… Being a nerd is cool. We can do mighty cool stuff. Let’s wait for the build to complete. After a few minutes you should end up with the last line in your terminal window looking like this:

BUILD SUCCESSFUL

That’s good news! This means that you now have a working RED5 build!
Let’s copy the conf directory from the dist folder to the current directory. (Don’t ask me why… Turns out this is important)

cp -r dist/conf .

Okay, so right now we have a build of the RED5 server. As far as servers go: This one should be ready to rock. Let’s check this out!

./red5.sh

You should get lots of more text scrolling across the screen (again, looks so harcore!). What this does is, it runs the RED5 server. If you wanna make sure your server is actually running, you should be able to see the webroot of Red5 when hitting your server at port 5080 (yourserver.com:5080)(watch the firewall ;-) Add ports 5080 and 1935 to the whitelist)
Note that the server is currently only running as long as you keep that terminal window open. Once you close it RED5 stops running. Let’s make sure RED5 can run on its own from now on. Hit CTRL+C to stop the process. (if you visit yourserver.com:5080 again, it should tell you the browser can’t open the page at that address)

Service

We will create a little service script for RED5. Let’s start here:

vi /etc/init.d/red5

You’ll be dropped into vi, a basic UNIX text editor.
Here we will write down the init script that will give us a simple API to start, stop, restart the server and get the status of the server.

Enter the following script into vi. Note: Copy pasting might be buggy, so first copy/paste this script into a local texteditor and make sure all quotes are normal quotes. I ran into this problem. For easy measure: You can download the script here. This version is copy/past-safe ;-)

#!/bin/bash
# For RedHat and cousins:
# chkconfig: 2345 85 85
# description: Red5 flash streaming server
# processname: red5
# Created By: Sohail Riaz (sohaileo@gmail.com)

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

Once you’ve pasted the text, hit ESC. Then type the following to save and quit vi:

:wq

On the bottom of the screen the ‘:wq‘ should appear (in a status bar style fashion)
Hit enter. Vi should close and the terminal window should look like before. To make sure you saved the init script correctly, just do this once again:

vi /etc/init.d/red5

You should now see the script you pasted earlier. If you don’t, you haven’t saved the script before properly. Go back a few steps and try again. If the script got saved, just enter the following to close vi again:

:q

Since this is unix land, we need to make sure this init script has permissions to actually be executed. Let’s do this! Do it using chmod, like this:

chmod +x /etc/init.d/red5

Now we should be able to start red5 by using this script. Give this a shot

/etc/init.d/red5 start

If your server responds by writing starting Red5: [ OK ], you’re golden. Let’s check the status!

/etc/init.d/red5 status

You should see something like

red5 (pid 11232) is running...

This means that the RED5 server is running on its own. We could close this terminal window and the RED5 server would stay up and running. That’s looking mighty good, right!?
However, whenever we reboot the VPS, the RED5 server won’t start by itself…yet. You know where I’m going with this, right?
In order for RED5 to start when the server boots, we need to do some chkconfig magic. First we need to add the RED5 service to chkconfig:

chkconfig --add red5

Now we need to tell chkconfig that red5 should start asap when booting:

chkconfig red5 on

That should do it… Red5 is installed, you have a simple way of restarting the RED5 service and it starts as soon as possible whenever the server starts. I’d say that’s all we need. Let’s have a little applause for yourself. You did it! You have RED5 running on your server! Now go and have fun with it :-)

Thank you

I think I (= we) should thank a lot of people and communities for what has just been done. All of these apps, binaries, sources and files have been shared for your freedom of using, experimenting and building apps with it. You didn’t have to pay anything for it. You just had to figure out how to use it. A little bit of gratitude is well in order.

At the same time I want to give credit to all of the people who published tutorials and manuals on their own site about how to install RED5 and other apps needed for this to work. Listed below are all the sources I referenced in order to compile this complete guide to RED5-awesomeness.

45 Comments

Add yours
  1. 1
    Davy

    Awesome blogpost Ronny!

    This is about as far as I got when creating my own Red5 applications.

    However, when I try to publish my projects from within the Eclipse plugin, they don’t appear in the Red5 admin interface. I guess I must be overlooking some kind of configuration parameter. (Hence my call for a sequel on Twitter)

    Thumbs up for your thorough guide! Looking forward to more sweetness! ;-)

  2. 2
    Ronny

    Well, I haven’t EVER used the admin interface to be honest :-P I still have to figure that one out. I did however record a screencast that demonstrates the complete walkthrough from ‘no eclipse and Red5′ to ‘Eclipse with Red5 plugin and Red5 testing server and your first Flash app that connects with the Red5 server’ ;-) But I might have to redo that… It was kinda bumpy and as it turns out I forgot to highlight a few important points ;-) I am however publishing (a redo of) that tutorial soon.

  3. 3
    Ammad

    just very simple red5 installation. please this link below.

    #cd /opt
    #wget gchats.com/downloads/red5-0.8.tar.gz
    #tar -zxf red5-0.8.tar.gz
    #rm -rf *.gz
    #cd red5
    #yum install nano
    #mv red5 /etc/init.d
    #sh red5.sh
    showing “Boot Start up to Complete” then press to Ctrl+C
    #mv red5 /etc/init.d
    #nano /etc/init.d/red5
    check it all lines and press Ctrl+X then enter
    #cd /etc/rc2.d
    #ln /etc/init.d/red5 S89red5 -s
    #cd ../rc3.d
    #ln /etc/init.d/red5 S89red5 -s
    #cd ../rc5.d
    #ln /etc/init.d/red5 S89red5 -s

    red5 installation completed.

    red5 start:
    #/etc/init.d/red5 start
    red5 check
    #/etc/init.d/red5 status
    red5 restart
    #/etc/init.d/red5 restart
    red5 stop
    #/etc/init.d/red5 stop

    red5 browser check
    http://yourip:5080

    showing blank page to installation is done

  4. 5
    Saravanan

    Hello Sir
    i Did everything as ur guidance everything ok but when i give that ./red5.sh the page is end with Cannot run without an instance id. and also i follow all ur steps and finally service red5 start also OK, but i cant open myip:5080 plz give me solution(i Installed Centos 6.2)

    Regards/
    Saravanan
    India.

  5. 6
    dsf

    Dude, YOU’re the man, thanks so much for this complete Red5 guide. This post is the most complete one and almost flawless , thank you :-)

    The only issue found was when saving the red5 batch file via Putty, like on your code is:
    vi /etc/init.d/red5 – after saving it will truncate the first lines of code and the error will look like :
    “/etc/init.d/red5: line 1: edHat: command not found”
    … if this happens just use:
    nano -w /etc/init.d/red5

    Hope this will save someone at least some couple of minutes :-) , and again thanks for sharing it.

  6. 10
    Orlando

    Thank you very much, Ronny. Your turorial is great!

    I have an issue while installing and configuring ant, an issue of the kind of :

    Error: JAVA_HOME is not defined correctly. We cannot execute /usr/lib/jvm/java-6-sun/bin/bin/java

    I solved the issue pointing the

    JAVA_HOME=/usr/lib/jvm/java-6-sun

    to the right directories.

  7. 11
    Martin

    Great post! Totally clear, but unfortunately I’ll get the same error as Saravanan.. Everything went well except the kick start of RED5 (./red5.sh) will end with the message ‘IllegalStateException: Cannot run without an instance id.’

    Any suggestions? Running a fresh CentOS 6.2 install.

  8. 12
    Kirsty

    Thanks for such a great and well written tutorial. Got me up and running without a hitch and I am still getting my head round SSH.

  9. 14
    Angela

    This is great, but I’m having a problem…when I try to start red5 I receive a strange error: line8: syntax error near unexpected token `;;’

    I can’t go any further :(

  10. 16
    Eric

    If you’re having the “Cannot run without an instance id.” issue. Be sure to properly set your server’s hostname. For me (CentOS 5.6), running the ‘setup’ command and using the GUI to configure the hostname solved the problem.

  11. 17
    I am

    hello

    I got following error when executing ./red5.sh

    org.springframework.remoting.rmi.RmiRegistryFactoryBean – Unexporting RMI registry
    Exception org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘red5.core’ defined in class path resource [red5.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.context.support.FileSystemXmlApplicationContext]: Constructor threw exception; nested exception is org.springframework.beans.FatalBeanException: Editor class not found; nested exception is java.lang.ClassNotFoundException: org.apache.mina.integration.beans.InetSocketAddressEditor

    PLS help me

  12. 18
    Devdatta

    Friends, I am installing red5 FMS on centos 5.6 and I am getting the following error after ‘ant dist’: Would you please help?

    BUILD FAILED
    /usr/local/red5/build.xml:202: The following error occurred while executing this line:
    /usr/local/red5/build.xml:216: The following error occurred while executing this line:
    /usr/local/red5/build.xml:167: impossible to resolve dependencies:
    resolve failed – see output for details

  13. 19
    Devdatta

    Friends, I am installing red5 FMS on centos 5.6 and I am getting the following error after ‘ant dist’: (There are so many [Ivy :resolve] commands run on the screen and lastly i get

    [ivy:resolve] :: problems summary ::
    [ivy:resolve] :::: WARNINGS
    [ivy:resolve] [FAILED ] org.jruby#jruby;1.6.7.2!jruby.jar: Downloaded file size doesn’t match expected Content Length for http://repo1.maven.org/maven2/org/jruby/jruby/1.6.7.2/jruby-1.6.7.2.jar. Please retry. (1769278ms)
    [ivy:resolve] [FAILED ] org.jruby#jruby;1.6.7.2!jruby.jar: Downloaded file size doesn’t match expected Content Length for http://repo1.maven.org/maven2/org/jruby/jruby/1.6.7.2/jruby-1.6.7.2.jar. Please retry. (1769278ms)
    [ivy:resolve] ==== central: tried
    [ivy:resolve] http://repo1.maven.org/maven2/org/jruby/jruby/1.6.7.2/jruby-1.6.7.2.jar
    [ivy:resolve] ::::::::::::::::::::::::::::::::::::::::::::::
    [ivy:resolve] :: FAILED DOWNLOADS ::
    [ivy:resolve] :: ^ see resolution messages for details ^ ::
    [ivy:resolve] ::::::::::::::::::::::::::::::::::::::::::::::
    [ivy:resolve] :: org.jruby#jruby;1.6.7.2!jruby.jar

    BUILD FAILED
    /usr/local/red5/build.xml:202: The following error occurred while executing this line:
    /usr/local/red5/build.xml:216: The following error occurred while executing this line:
    /usr/local/red5/build.xml:167: impossible to resolve dependencies:
    resolve failed – see output for details

  14. 25
    ramon

    Hey . i have a problem with safari when we are in the chat the webcam shots off after 10 minutes and sometimes after 30 minutes. can u please help me ? i dont have the problem with other browsers. i dont know how to do the settings ;-)

    thanks !!

  15. 27
    Erkan

    Hello,

    Doing everything as you said. But constantly having trouble with an error like this ..

    Checked out revision 4541.
    [root@srv src]# mv red5 /usr/local/
    [root@srv src]# cd /usr/local/red5
    [root@srv red5]# ant prepare
    Buildfile: build.xml does not exist!
    Build failed

    The files looks as follows;

    [root@srv red5]# ls -l
    total 32
    -rw-r–r– 1 root root 1871 Jan 24 13:57 build.properties
    -rw-r–r– 1 root root 1324 Jan 24 13:57 license.txt
    -rw-r–r– 1 root root 19926 Jan 24 13:57 pom.xml
    drwxr-xr-x 5 root root 4096 Jan 24 13:57 src

    The correct version of Java installed,

    ant 1.8.4 installed,

    Svn board,

    System is not installed anything else.

    My system, CentOS 6 64-bit. There directadmin.

  16. 28
    permartin

    Erkan, I have the exact same problem!! I run on a Centos 32bit system.

    : ant prepare
    : Buildfile: build.xml does not exist!
    : Build failed

    PLEEAASE somebody help !!

  17. 29
    ovan

    still got failed while ant dist,

    [root@video red5]# ant dist
    Buildfile: /usr/local/red5/build.xml
    [taskdef] Could not load definitions from resource org/apache/ivy/ant/antlib.xml. It could not be found.

    -library.check:
    [echo] Java: java.home is /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre and the target version is 1.6
    [echo] Ant: ant.home is /usr/local/ant and the target version is Apache Ant(TM) version 1.8.4 compiled on May 22 2012

    -java6.check:
    [echo] Using Java 1.6

    prepare:

    compile:
    [echo] javac version: 1.6
    [echo] Not using the Eclipse IDE
    [echo] Compiler adapter name: modern
    [taskdef] Could not load definitions from resource org/apache/ivy/ant/antlib.xml. It could not be found.

    compile-core:
    [taskdef] Could not load definitions from resource org/apache/ivy/ant/antlib.xml. It could not be found.

    retrieve:

    BUILD FAILED
    /usr/local/red5/build.xml:235: The following error occurred while executing this line:
    /usr/local/red5/build.xml:252: The following error occurred while executing this line:
    /usr/local/red5/build.xml:191: Problem: failed to create task or type antlib:org.apache.ivy.ant:settings
    Cause: The name is undefined.
    Action: Check the spelling.
    Action: Check that any custom tasks/types have been declared.
    Action: Check that any / declarations have taken place.
    No types or tasks have been defined in this namespace yet

    This appears to be an antlib declaration.
    Action: Check that the implementing library exists in one of:
    -/usr/local/ant/lib
    -/root/.ant/lib
    -a directory added on the command line with the -lib argument

    Total time: 0 seconds
    [root@video red5]#

    can you help me with this please

  18. 30
    Saurabh

    We bought this server 3 days ago:
    1 x 3.4GHz / 32GB
    Intel E1240-V2 3.4GHz CPU
    32GB ECC 1333MHz RAM
    1 x 120GB SSD
    10TB Data Transfer
    100Mbps Premium IP

    We are running a streaming server (Red5) here. It is being used to record user’s webcam streams. We’re facing huge frame drops onthis server, resulting in jerky videos.

    Earlier we ran the setup on a domestic PC on a 1 Mbps line. We’ve successfully tested it from various locations throughout the world, including the US. We’ve recorded multiple videos without any frame drops, but no matter what connection speed, recording to your server gives us frame drops.

    The set up on this server was copied as-it-is from our domestic PC. No changes were made, except the file paths.

    What could possibly be the problem? Something on the Red5 part of things is dropping frames. The client side, a flash recorder is the same with the same recording settings.

    We are using: Red5 0.8, Flash-VideoIO recorder on Ubuntu 12.04 LTS x64.

  19. 31
    donnacha

    Same problem as Erkan, Permartin and Ovan:

    “build.xml does not exist”

    Sadly, some change to Red5, since at least January 24th 2013, has made this July 2011 tutorial redundant.

    Has anyone come across a more recent guide?

  20. 32
    Merdicat

    Been hunting forever on this bit. I am having the same problem as Erkan, permartin, and donnacha.

    CentOS 64-bit. Everything went smooth up until the build.xml does not exist.

    I needs this for my server too..

    I am a total noob with linux, so me trying to solve this is like handing a pidgeon archetectual gear and asking it to recreate a 3D version of the Monalisa as a structure while defining civil engineering possibilities..

    :|

    Just sayin :|

    Anyone got an updated guide for the updated Red5/CentOS 6 64-bit?

    • 39
      Ronny

      Hi Chan,

      The last time I installed this I ran the same process as on this blogpost (that’s about 3 months back) and I had no issues whatsoever. are you sure you’re in the right directory when entering the build commands? Check in the other folders maybe for the build.xml file. I remember having had that issue a few years back and I found I was in the wrong folder to initiate the build command. I hope you figure it out. If the build.xml file isn’t there then there’s something wrong either with the SVN repo (and you should indeed try to pull another version) or something went wrong during the prepare of the build.

      I’m afraid I’m a linux noob myself so I can’t give much more guidance than this.
      Good luck!

  21. 40
    Bron

    This works perfectly – and if you download the tar from the Red5 download page, you can skip the build portion and be up and running even faster. Thanks!

  22. 43
    Giva

    Can you tell me why this happeded when tring to install?
    $ ant prepare
    Buildfile: build.xml does not exist!
    Build failed
    instead of Bulid successfull.

+ Leave a Comment