May
21
Installing Red5 Media Server on CentOS 5.5 / Fedora
ByThis post details the steps I took to install Red5 from source on a CentOS 5.5 base server.
1. Install Java using yum. (The -y flag provides a ‘yes’ answer to all prompts.)
yum -y install java-1.6.0-openjdk java-1.6.0-openjdk-devel
2. Install the Apache ant binary. I downloaded the most recent release one directly from Apache’s archives. The version installed using yum (and default repositories) will not compile Red5.
cd /usr/src wget http://archive.apache.org/dist/ant/binaries/apache-ant-1.8.1-bin.tar.bz2 tar jxvf apache-ant-1.8.1-bin.tar.bz2 mv apache-ant-1.8.1 /usr/local/ant
3. Set important Java environment variables.
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
4. You should also add them to
bashrc so they’re available the next time you log in.
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
5. Install subversion with yum. If you did a base install of CentOS, subversion will not be preinstalled.
yum -y install subversion
6. Check out the Red5 source.
cd /usr/src svn checkout http://red5.googlecode.com/svn/java/server/trunk/ red5
7. Build Red5 with ant.
mv red5 /usr/local/ cd /usr/local/red5 ant prepare ant dist
8. Start Red5.
cp -r dist/conf . ./red5.sh
9. Create a startup script (optional):
vi /etc/init.d/red5
Then enter this text into the file.
#!/bin/bash
# chkconfig: 2345 80 80
# description: Red5 streaming server
# processname: red5
. /etc/rc.d/init.d/functions
[ -r /etc/sysconfig/red5 ] && . /etc/sysconfig/red5
RETVAL=0
case "$1" in
start)
echo -n "Starting red5: "
cd /usr/local/red5
/usr/local/red5/red5.sh >/dev/null 2>/dev/null &&
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
echo $! > /var/run/red5.pid
touch /var/lock/subsys/red5
fi
[ $RETVAL -eq 0 ] && success $"red5 startup" || failure $"red5 startup"
echo
;;
stop)
echo -n $"Stopping down red5: "
killproc -p /var/run/red5.pid
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/red5
;;
restart)
$0 stop
$0 start
;;
status)
status red5 -p /var/run/red5.pid
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
RETVAL=1
esac
exit $RETVAL
10. Set permissions on the script.
chmod a+x /etc/init.d/red5 chkconfig red5 on
11. Add necessary ports to the iptables file.
vi /etc/sysconfig/iptables
Then add the following lines:
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 5080 -j ACCEPT -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 1935 -j ACCEPT
You may also want to add exceptions for 8443, 8088, 9035, 1936, and 9999 if necessary for your application,
service iptables restart
You may want to restart the server, and the Red5 test page can be accessed at http://localhost(or servername):5080/


1 Comments
August 4th, 2010 at 4:02 pm
Thank you for the tutorial!