一、安装nginx所需环境:
yum -y install gcc gcc-c++ autoconf automake make
yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel
二、下载安装nginx+rtmp包
cd /usr/local
# 下载nginx,如果没有下载命令,安装命令:yum -y install wget
wget http://nginx.org/download/nginx-1.13.12.tar.gz
tar -zxvf nginx-1.13.12.tar.gz
# 创建nginx安装目录和模块目录
mkdir -p /usr/local/nginx/module
# 创建视频数据存放位置
mkdir -p /usr/local/nginx/myapp
cd /usr/local/nginx/module
# 下载nginx-rtmp-module,下载后的文件夹名叫nginx-rtmp-module(没有安装git的请安装,执行语句的时候没有git会提示你, yum -y install git)
git clone https://github.com/arut/nginx-rtmp-module.git
# 下载成功后,进入nginx目录,该目录根据具体安装路径
cd /usr/local/nginx-1.13.12/
./configure --prefix=/usr/local/nginx --add-module=/usr/local/nginx/module/nginx-rtmp-module
# 编译并安装
make && make install
# 启动nginx
/usr/local/nginx/sbin/nginx
浏览器访问:http://127.0.0.1,出现welcome页面
三、配置nginx与nginx-rtmp-module
1.将nginx-rtmp-module中的配置文件nginx.conf,覆盖到nginx中
cp /usr/local/nginx/module/nginx-rtmp-module/test/nginx.conf /usr/local/nginx/conf
2.编辑nginx文件夹下的配置文件
vim /usr/local/nginx/conf/nginx.conf
编辑五处代码:
hls on;
hls_path /usr/local/nginx/myapp;
application vod{
play /usr/local/nginx/vod/flvs;
}
location /stat.xsl {
root /usr/local/nginx/module/nginx-rtmp-module/;
}
location /rtmp-publisher {
root /usr/local/nginx/module/nginx-rtmp-module/test;
}
location / {
root /usr/local/nginx/module/nginx-rtmp-module/test/www;
}
3.修改展示页面
3.1、vim /usr/local/nginx/module/nginx-rtmp-module/test/www/index.html
3.2:vim /usr/local/nginx/module/nginx-rtmp-module/test/www/record.html
3.3:点播配置,创建视频存放位置,
mkdir -p /usr/local/nginx/vod/flvs
,然后上传一个mp4视频至该文件夹
编辑页面:vim /usr/local/nginx/module/nginx-rtmp-module/test/rtmp-publisher/player.html
4.重新加载:/usr/local/nginx/sbin/nginx -s reload
,如果重启失败,直接启动试一下/usr/local/nginx/sbin/nginx
5.重启后浏览器访问:http://192.168.246.178:8080/,注意打开浏览器的flash允许访问
6、浏览器访问
http://192.168.246.178:8080/rtmp-publisher/player.html
转载原文:
https://www.cnblogs.com/360minitao/p/12039707.html