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 xjvf 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 co http://red5.googlecode.com/svn/java/server/tags/1_0/ 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
#!/bin/sh
# Startup script for Red5 flash streaming server on RedHat/CentOS (cPanel)
# chkconfig: 2345 95 55
# 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
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
-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
service iptables restart