CentOS 6.2下安装并配置Red5流媒体服务器
环境说明
步骤1 卸载自带的OpenJDK,具体方法,百度上有很多。建议使用yum –y remove方式 步骤2 安装Sun JDK1.6,具体方法,百度上有很多 步骤3 安装Red5(重点) 1、下载red5并解压到/usr/local/red5目录 2、测试Red5 cd /usr/local/red5 ./red5.sh 如果最后一行显示:Installer service created,则说明安装成功了。此时可ctrl+c退出red5状态监测。 如果需要将Red5服务配置成系统服务(并可以设置在开机启动或手动启动) 3、编辑启动脚本 按i键,在insert模式下,将以下内容粘贴进去。ESC,shift+ZZ保存退出。也可直接下载以下内容的txt文档,以免因格式造成错误。http://www.sohailriaz.com/downloads/red5.txt 提示:直接下载的red5.txt放到/etc/init.d/中时,去掉扩展名,并且内容上需要添加几句代码 最重要的是export JAVA_HOME=JDK的具体目录 vi /etc/init.d/red5 #!/bin/bash # For RedHat and cousins: # chkconfig: 2345 85 85 # description: Red5 flash streaming server # processname: red5 # Created By: Yulijia (yu_lijia@163.com) PROG=red5 RED5_HOME=/usr/local/red5 TOSTART=$RED5_HOME/$PROG.sh TOSTOP=$RED5_HOME/red5-shutdown.sh PIDFILE=/var/run/$PROG.pid JAVA_HOME=/usr/java/jdk1.6.0_32 # Source function library . /etc/rc.d/init.d/functions [ -r /etc/sysconfig/red5 ] && . /etc/sysconfig/red5 RETVAL=0 export JAVA_HOME=$JAVA_HOME case "$1" in start) echo -n $"Starting $PROG: " cd $RED5_HOME $TOSTART >/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: " cd $RED5_HOME #$TOSTOP >/dev/null 2>/dev/null & killproc -p $PIDFILE RETVAL=$? if [ $RETVAL -eq 0 ]; then rm -f /var/lock/subsys/$PROG fi [ $RETVAL -eq 0 ] && success $"$PROG stop" || failure $"$PROG stop" echo ;; restart) $0 stop $0 start ;; status) status $PROG -p $PIDFILE RETVAL=$? ;; *) echo $"Usage: $0 {start|stop|restart|status}" RETVAL=1 esac exit $RETVAL 注意: 需要对/etc/init.d/functions进行授权 chmod +x /etc/init.d/functions 否则killproc函数无法识别,将导致无法停止red5服务 其它的需要授权的操作 chmod +x /etc/rc.d/init.d/red5 chmod +x /usr/local/red5/red5.sh chmod +x /usr/local/red5/red5-shutdown.sh 步骤4将启动脚本添加到服务 /sbin/chkconfig --add red5 说明:添加服务 /sbin/chkconfig red5 on 说明:on表示开机自动启动 off表示开机不自动,需要手动启动 /sbin/service red5 start 说明:手动启动服务 步骤5设置CentOS防火墙 如果用setup设置防火墙,将会覆盖以下内容,需重新设置。如果只是测试,建议关闭防火墙,以免不必要的障碍 在/etc/sysconfig/iptables文件中 -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT 下增加以下内容: -A INPUT -m state --state NEW -m tcp -p tcp --dport 5080 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 1935 -j ACCEPT 重启防火墙 /sbin/service iptables restart 查看端口是否开放 /sbin/iptables -L -n 步骤6测试Red5 在浏览器中访问 http://127.0.0.1:5080 * 注意Red5中所有Demo需要先安装后运行,在前述页面点击Install即可安装 可能会遇到的其它问题(我没有遇到) http://ip:5080/demos/port_tester.html 测试网站的端口情况,如果发现都是失败,或许还有问题: 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 02步 /usr/local/red5/red5.sh 03步 output trancated 04步 [INFO] [main] org.red5.server.tomcat.TomcatLoader – RTMPT server bean was not found 05步 [INFO] [main] org.red5.server.tomcat.TomcatLoader – RTMPS server bean was not found 06步 output truncated 07步 If you see this you have to uncomment the RTMPT and RTMPTS TomcatLoader in/usr/local/red5/conf/red5-core.xml 08步 vi /usr/local/red5/conf/red5-core.xml 09步 Search for a lines <!– RTMPT –> <!– <bean id=”rtmpt.server” class=”org.red5.server.net.rtmpt.TomcatRTMPTLoader” init-method=”init” lazy-init=”true”> 13步 Remove the <!– from start of <bean and –> from end of 14步 Same goes for RTMPS 查找代码: <!– RTMPS –> <!– <bean id=”rtmps.server” class=”org.red5.server.net.rtmps.TomcatRTMPSLoader” init-method=”init” lazy-init=”true”> 18步 Remove the <!– from start of <bean and –> from end of 19步 Restart the red5 services and connection fails problem will be fixed. 20步 If you any question please use comments. (责任编辑:IT) |