Friday, April 19, 2013

Install RED5 server on Linux


Install RED5 server on Linux

Following blog post will describe how to install RED5 server on Centos 5.7 (Final)

Red5 Working :

Red5 server converts the video file to the flash file and we everyone knows that flash files play instantly once someone accesses it. Here when we request or select a particular video, the video script will send the video(stream the video) to red5 server. Red5 will convert the video file to flash and sends the output to the video script to display on the browser. Lot of video scripts are being used now a days like dolphin, videowhisper etc for the site. You can configure the admin panel using the server's IP and port details.

Installation Steps:

1. Download and Install Java:
Red5 is a JAVA server. So install Java using yum.

[root@server ~]# yum -y install java-1.6.0-openjdk java-1.6.0-openjdk-devel

2. Install SVN:
SVN will required to fetch latest release of RED5 source from SVN repository at Google Code.

[root@server ~]# yum install subversion

3. Download and Install Ant & Ivy:
Ant will need to compile RED5 server code. Ant comes in binary form, so just download and install it in /usr/local directory.
First off let’s change to another directory.

[root@server ~]# cd /usr/src
[root@server src]# wget http://archive.apache.org/dist/ant/binaries/apache-ant-1.8.2-bin.tar.bz2
[root@server src]# tar jxvf apache-ant-1.8.2-bin.tar.bz2
[root@server src]# mv apache-ant-1.8.2 /usr/local/ant

[root@server src]# svn co https://svn.apache.org/repos/asf/ant/ivy/core/trunk ivy
[root@server src]# cd ivy
[root@server src]# /usr/local/ant/bin/ant jar
[root@server src]# cp build/artifact/jars/ivy.jar /usr/local/ant/lib/

4. Export Variables for Ant and Java:
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.

[root@server src]# export ANT_HOME=/usr/local/ant
[root@server src]# export JAVA_HOME=/usr/lib/jvm/java
[root@server src]# export PATH=$PATH:/usr/local/ant/bin

5. Actually Installing the RED5 Server:
Source:
Let’s get the RED5 source:

[root@server src]# svn co http://red5.googlecode.com/svn/java/server/tags/1_0/ 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

[root@server src]# mv red5 /usr/local/
[root@server src]# cd /usr/local/red5

This is the folder where all the source files reside. From here on, we prepare and build the red5 source.

[root@server red5]# /usr/local/ant/bin/ant prepare
[root@server red5]# /usr/local/ant/bin/ant dist

Wait for few minutes to . After a few minutes you should end up with the last line in your terminal window looking like this:

BUILD SUCCESSFUL

This means that you now have a working RED5 build!

Copy the conf directory from the dist folder to the current directory and test the red5 installation.

[root@server red5]# cp -r dist/conf .
[root@server red5]# ./red5.sh

Make sure your server is actually running, you should be able to see the webroot of Red5 when hitting your server at port 5080 (http://yourserver.com:5080)

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.

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

[root@server ~]# vi /etc/init.d/red5 [Enter the following script into vi.]
#!/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

7. Assign execute permission to red5 script.

[root@server ~]# chmod +x /etc/init.d/red5

8. Now start the service

[root@server ~]# service red5 start OR /etc/init.d/red5 start
9. To start RED5 when the server boots.

[root@server ~]# chkconfig --add red5
[root@server ~]# chkconfig red5 on

10. To Install RED5 demos

[root@server ~]# cd /usr/local/red5/webapps/root
[root@server root]# svn checkout http://red5.googlecode.com/svn/java/server/tags/0_9_1/webapps/root/demos/

11. Test

Now test the RED5 installation by opening following URL in browser.

http://yourserverip:5080/

13 comments:

Anonymous said...

I tried to install red5 0.9.1 but it gives me error:

./red5.sh
Running on Linux
Starting Red5
Red5 root: /usr/src/red5/dist
Configuation root: /usr/src/red5/dist/conf
Exception in thread "main" java.lang.NumberFormatException: For input string: "147j"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:481)
at java.lang.Integer.valueOf(Integer.java:570)
at org.red5.classloading.ClassLoaderBuilder.scrubURLList(ClassLoaderBuilder.java:505)
at org.red5.classloading.ClassLoaderBuilder.build(ClassLoaderBuilder.java:179)
at org.red5.classloading.ClassLoaderBuilder.build(ClassLoaderBuilder.java:97)
at org.red5.server.Bootstrap.bootStrap(Bootstrap.java:126)
at org.red5.server.Bootstrap.main(Bootstrap.java:50)

Anup Dubbewar said...

Remove or rename the jar file in your lib directory that contains "147ss"

Anonymous said...

this works from me but the demos not install any tip about how install them

Anup Dubbewar said...

[root@server ~]# cd /usr/local/red5/webapps/root
[root@server root]# svn checkout http://red5.googlecode.com/svn/java/server/tags/0_9_1/webapps/root/demos/

Anonymous said...

You are awesome !!!!

It works

Srinivas said...

Hi,

I am getting this error:
".: 13: Can't open /etc/rc.d/init.d/functions".

Can you please tell the solution for this.

Anup Dubbewar said...

Hello @Srinivas,

On which Linux platform you are running the script ?

Above script is written for CentOS,
If you are using Ubuntu then it uses
/lib/lsb/init-functions as the init function libraries.

Try replacing:

# Source function library
. /etc/rc.d/init.d/functions

with this:

# Source function library
. /lib/lsb/init-functions

Srinivas said...

Hi,
I tried with this also..

# Source function library
. /lib/lsb/init-functions

still i am getting error.

Anonymous said...

i installed videowhisper in my red5 server and give the rtmp server path like rtmp://my-ip:5080/videowhisper/ but it not work properly.
It shows RTMP server failer.Pls help me to fix this problem

Father's House Ministries said...

having issues, I get:

[/usr/src]# mv apache-ant-1.8.2 /usr/local/ant
mv: cannot stat `apache-ant-1.8.2': No such file or directory

then
[/usr/src/ivy]# /usr/local/ant/bin/ant jar
Error: JAVA_HOME is not defined correctly.
We cannot execute /usr/local/jdk/bin/java

any thoughts?

Anonymous said...

i install but showing this erorr ]# /etc/init.d/red5 status
red5 dead but pid file exists

Unknown said...

svn co http://red5.googlecode.com/svn/java/server/tags/1_0/ red5
svn: E160013: Unable to connect to a repository at URL 'http://red5.googlecode.com/svn/java/server/tags/1_0'
svn: E160013: '/svn/java/server/tags/1_0' path not found

Unknown said...

svn checkout http://red5.googlecode.com/svn/java/server/tags/0_9_1/webapps/root/demos/
svn: E160013: Unable to connect to a repository at URL 'http://red5.googlecode.com/svn/java/server/tags/0_9_1/webapps/root/demos'
svn: E160013: '/svn/java/server/tags/0_9_1/webapps/root/demos' path not found