阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

Ubuntu 16.04 安装搭建Red5流媒体服务器

197次阅读
没有评论

共计 8318 个字符,预计需要花费 21 分钟才能阅读完成。

在网上看了不少安装 red5-server 的方法,在我电脑上都好像安装不成功,本来是很简单的事,因为刚接触,结果费了不少时间。这里整理出 Ubuntu 16.04 成功安装的方法,以便给搭建一个参考。

(一)安装 JDK

1. 终端输入:apt-cache search openjdk

运行结果:

linuxidc@linuxidc:~/test/RTMP$ sudo apt-cache search openjdk
[sudo] password for linuxidc:
Sorry, try again.
[sudo] password for linuxidc:
default-jdk – Standard Java or Java compatible Development Kit
default-jdk-doc – Standard Java or Java compatible Development Kit (document
default-jdk-headless – Standard Java or Java compatible Development Kit (hea
default-jre – Standard Java or Java compatible Runtime
default-jre-headless – Standard Java or Java compatible Runtime (headless)
openjdk-8-dbg – Java runtime based on OpenJDK (debugging symbols)
openjdk-8-demo – Java runtime based on OpenJDK (demos and examples)
openjdk-8-doc – OpenJDK Development Kit (JDK) documentation
openjdk-8-jdk – OpenJDK Development Kit (JDK)
openjdk-8-jdk-headless – OpenJDK Development Kit (JDK) (headless)
openjdk-8-jre – OpenJDK Java runtime, using Hotspot JIT
openjdk-8-jre-headless – OpenJDK Java runtime, using Hotspot JIT (headless)
openjdk-8-jre-jamvm – Alternative JVM for OpenJDK, using JamVM
openjdk-8-source – OpenJDK Development Kit (JDK) source files
icedtea-8-plugin – web browser plugin based on OpenJDK and IcedTea to execut
jtreg – Regression Test Harness for the OpenJDK platform
libhsdis0-fcml – HotSpot disassembler plugin using FCML
libreoffice – office productivity suite (metapackage)
openjdk-8-jre-dcevm – Alternative VM for OpenJDK 8 with enhanced class redef
openjdk-8-jre-zero – Alternative JVM for OpenJDK, using Zero/Shark
openjdk-9-dbg – Java runtime based on OpenJDK (debugging symbols)
openjdk-9-demo – Java runtime based on OpenJDK (demos and examples)
openjdk-9-doc – OpenJDK Development Kit (JDK) documentation
openjdk-9-jdk – OpenJDK Development Kit (JDK)
openjdk-9-jdk-headless – OpenJDK Development Kit (JDK) (headless)
openjdk-9-jre – OpenJDK Java runtime, using Hotspot JIT
openjdk-9-jre-headless – OpenJDK Java runtime, using Hotspot JIT (headless)
openjdk-9-source – OpenJDK Development Kit (JDK) source files
uwsgi-app-integration-plugins – plugins for integration of uWSGI and applica
uwsgi-plugin-jvm-openjdk-8 – Java plugin for uWSGI (OpenJDK 7)
uwsgi-plugin-jwsgi-openjdk-8 – JWSGI plugin for uWSGI (OpenJDK 7)
uwsgi-plugin-ring-openjdk-8 – Closure/Ring plugin for uWSGI (OpenJDK 7)
uwsgi-plugin-servlet-openjdk-8 – JWSGI plugin for uWSGI (OpenJDK 7)
java-package – Utility for creating Java Debian packages

2. 这里我们安装 openjdk-8-jdk,因为我安装 openjdk-9-jdk 的时候有出错。

运行安装命令:

sudo apt-get install openjdk-8-jdk

3. 测试是否安装成功:java -version

linuxidc@linuxidc:~$ java -version
openjdk version “1.8.0_121”
OpenJDK Runtime Environment (build 1.8.0_121-8u121-b13-0ubuntu1.16.04.2-b13)
OpenJDK 64-Bit Server VM (build 25.121-b13, mixed mode)

4. 配置 java_home 变量:

运行:echo export JAVA_HOME=”/usr/lib/jvm/Java-8-openjdk-amd64/”>>~/.bashrc 添加变量

source .bashrc  使变量生效

linuxidc@linuxidc:~$ $JAVA_HOME
linuxidc@linuxidc:~$ echo export JAVA_HOME=”/usr/lib/jvm/java-8-openjdk-amd64/”>>~/.bashrc
linuxidc@linuxidc:~$ $JAVA_HOME
linuxidc@linuxidc:~$ source .bashrc
linuxidc@linuxidc:~$ echo $JAVA_HOME
/usr/lib/jvm/java-8-openjdk-amd64/

(二)安装 red5

1. 下载 red5 Linux 安装包:https://github.com/Red5/red5-server/releases,国外网站,下载很慢

—————————————— 分割线 ——————————————

red5-server-1.0.9-M6 也可以到 Linux 公社 1 号 FTP 服务器下载

FTP 地址:ftp://ftp1.linuxidc.com

用户名:ftp1.linuxidc.com

密码:www.linuxidc.com

在 2017 年 LinuxIDC.com/ 9 月 /Ubuntu 16.04 安装搭建 Red5 流媒体服务器 /

下载方法见 http://www.linuxidc.com/Linux/2013-10/91140.htm

—————————————— 分割线 —————————————— 

2. 创建目录:

mkdir -p /usr/share/red5

3. 设置环境变量:

export RED5_HOME=/usr/share/red5

4. 将安装包解压到目录

/usr/share/red5

5. 开始运行 red5

cd /usr/share/red5

./red5.sh &

6. 结束运行 red5

cd /usr/share/red5

./red5-shutdown.sh

安装结束

测试 red5 是否安装成功:

(1)运行 red5

(2)浏览器输入:本地 IP:5080

比如我的 IP 地址为 192.168.0.6,则输入:http://192.168.0.6:5080/  出现下面界面表示安装成功。

Ubuntu 16.04 安装搭建 Red5 流媒体服务器

附启动脚本

Configure init script

#!/bin/sh
#
# /etc/init.d/red5 — startup script for the red5 server
#
# Based on the tomcat6 init script.
# Written by Miquel van Smoorenburg <miquels@cistron.nl>.
# Modified for Ubuntu red5 by Fred Dixon <ffdixon@bigbluebutton.org>
# Modified for Debian GNU/Linux by Ian Murdock <imurdock@gnu.ai.mit.edu>.
# Modified for Tomcat by Stefan Gybas <sgybas@debian.org>.
# Modified for Tomcat6 by Thierry Carrez <thierry.carrez@ubuntu.com>.
#
### BEGIN INIT INFO
# Provides:          red5
# Required-Start:    $local_fs $remote_fs $network
# Required-Stop:    $local_fs $remote_fs $network
# Should-Start:      $named
# Should-Stop:      $named
# Default-Start:    2 3 4 5
# Default-Stop:      1
# Short-Description: Start red5.
# Description:      Start the red5 service.
### END INIT INFO

set -e

PATH=/bin:/usr/bin:/sbin:/usr/sbin
NAME=red5
DESC=”Red5 Server”
RED5_HOME=/mnt/opt/$NAME
DEFAULT=/etc/default/$NAME
UMASK=0002

# These variables are needed by Xuggler
export XUGGLE_HOME=/usr/local
export PATH=$PATH:$XUGGLE_HOME/bin
export LD_LIBRARY_PATH=$XUGGLE_HOME/lib:$LD_LIBRARY_PATH

if [`id -u` -ne 0]; then
        echo “You need root privileges to run this script”
        exit 1
fi
 
# Make sure red5 is started with system locale
if [-r /etc/default/locale]; then
        . /etc/default/locale
        export LANG
fi

. /lib/lsb/init-functions
. /etc/default/rcS

# The following variables can be overwritten in $DEFAULT

# The first existing directory is used for JAVA_HOME (if JAVA_HOME is not
# defined in $DEFAULT)
JDK_DIRS=”/usr/lib/jvm/java-6-openjdk /usr/lib/jvm/java-6-sun /usr/lib/jvm/java-1.5.0-sun /usr/lib/j2sdk1.5-sun /usr/lib/j2sdk1.5-ibm”

# Look for the right JVM to use
for jdir in $JDK_DIRS; do
    if [-r “$jdir/bin/java” -a -z “${JAVA_HOME}” ]; then
        JAVA_HOME=”$jdir”
    fi
done
export JAVA_HOME

# Output file
if [-z “$OUT_FILE”]; then
        OUT_FILE=/var/log/red5.out
fi

# End of variables that can be overwritten in $DEFAULT

# overwrite settings from default file
if [-f “$DEFAULT”]; then
        . “$DEFAULT”
fi

if [! -f “$RED5_HOME/red5.jar”]; then
        log_failure_msg “$NAME is not installed”
        exit 1
fi

#
# Function to wait if there are connections still open for 1935.  Some browsers hang on to a connection
# that prevents a ./red5 restart from binding to port 1935
#
wait_1935_close () {
        ACTIVE=$(netstat -ant | grep 1935 | wc | awk -F ‘ ‘ ‘{print $1}’)
        if [$ACTIVE != 0]; then
                echo -n ”  Waiting for $ACTIVE connections on 1935 to close before starting Red5 “
                while [$ACTIVE != 0]; do
                        echo -n “.”
                        sleep 5
                        ACTIVE=$(netstat -ant | grep 1935 | wc | awk -F ‘ ‘ ‘{print $1}’)
                done
        fi
        echo
}

# Define other required variables
RED5_PID=”/var/run/$NAME.pid”

RED5_MAINCLASS=org.red5.server.Bootstrap
RED5_CLASSPATH=”$RED5_HOME/boot.jar:$RED5_HOME/conf:$RED5_HOME/lib/ejb3-persistence.jar”
JAVA_OPTS=”-Dpython.home=lib -Xms128M -Xmx128M -Dred5.root=$RED5_HOME -Dlogback.ContextSelector=org.red5.logging.LoggingContextSelector -Dcatalina.useNaming=true -Djava.security.debug=failure -cp $RED5_CLASSPATH org.red5.server.Bootstrap”

case “$1” in
  start)
        if [-z “$JAVA_HOME”]; then
                log_failure_msg “no JDK found – please set JAVA_HOME”
                exit 1
        fi

        if [! -d “$RED5_HOME/conf”]; then
                log_failure_msg “invalid RED5_HOME: $RED5_HOME”
                exit 1
        fi

        log_daemon_msg “Starting $DESC” “$NAME”
        if start-stop-daemon –start –test –pidfile $RED5_PID \
                –startas “$JAVA_HOME/bin/java” \
                >/dev/null; then

                wait_1935_close

                start-stop-daemon –start –background –make-pidfile –chuid red5  –umask $UMASK \
                        –chdir $RED5_HOME –pidfile $RED5_PID –startas “$JAVA_HOME/bin/java” — $JAVA_OPTS

                sleep 5

                # Because we pushed it into the background, we need to check it’s status
                if start-stop-daemon –test –start –pidfile $RED5_PID –startas “$JAVA_HOME/bin/java” >/dev/null; then
                        log_end_msg 1
                else
                        log_end_msg 0
                fi
        else
                log_progress_msg “(already running)”
                log_end_msg 0
        fi
        ;;
  stop)
        log_daemon_msg “Stopping $DESC” “$NAME”
        if start-stop-daemon –start –test –pidfile $RED5_PID \
                –startas “$JAVA_HOME/bin/java” \
                >/dev/null; then
                log_progress_msg “(not running)”
        else
                start-stop-daemon –stop –pidfile $RED5_PID \
                        –startas “$JAVA_HOME/bin/java”
                sleep 5
                rm -f $RED5_PID
        fi
        log_end_msg 0
        ;;
  status)
        if start-stop-daemon –start –test –pidfile $RED5_PID \
                –startas “$JAVA_HOME/bin/java” \
                >/dev/null; then

                if [-f “$RED5_PID”]; then
                    log_success_msg “$DESC is not running, but pid file exists.”
                        exit 1
                else
                    log_success_msg “$DESC is not running.”
                        exit 3
                fi
        else
                log_success_msg “$DESC is running with pid `cat $RED5_PID`”
        fi
        ;;
  restart|force-reload)
        if start-stop-daemon –test –stop –pidfile “$RED5_PID” \
                –startas “$JAVA_HOME/bin/java” \
                >/dev/null; then
                $0 stop
                sleep 1
        fi
        $0 start
        ;;
  *)
        log_success_msg “Usage: $0 {start|stop|restart|force-reload|status}”
        exit 1
        ;;
esac

exit 0 

本文永久更新链接地址 :http://www.linuxidc.com/Linux/2017-09/146715.htm

正文完
星哥玩云-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-21发表,共计8318字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中