12:nginx架设 rtmp直播
首先在之前 所安装的nginx是用 yum 源安装的。却不能为nginx添加他的模块 所以要用wget来下载源文件 来进行源码配置与安装。开搞
[root@localhost ~]# wget  nginx-1.6.3.tar.gz
#下载nginx源文件
[root@localhost ~]# tar xvf nginx-1.6.3.tar.gz                                                            #解压文件
因为这里需要用到  nginx-rtmp-moudle 这个模块  所以需要下载他 
[root@localhost ~]# yum install git                #下载git 因为源码在git上。
[root@localhost ~]# git clone https://github.com/arut/nginx-rtmp-module
我把他安装到了 root目录下 此时此刻他的地址应该是 /root/nginx-rtmp-module 我需要记住这个地址。
接下来安装 nginx-1.6.3
[root@localhost ~]# cd nginx-1.6.3                    #进入nginx源文件
[root@localhost ~]# ./configure --add-module=/root/nginx-rtmp-module  #配置系统参数。最后可以用 nginx -V来查看所用的环境配置,
[root@localhost ~]# make #编译
[root@localhost ~]# make install  #安装
当安装好了之后 nginx 来看下需要用到的目录结构
安装目录 /usr/local/nginx
命令程序 /usr/local/nginx/sbin/nginx -v # 就是他的命令 ,因为没有设置环境变量 ,这里看了一下nginx的版本号
配置文件 /usr/local/nginx/conf/nginx.conf #这个文件用于操作反向代理。
暂时用到的都看完了 这个时候需要配置 rtmp了 。。感觉很麻烦,那就用这个模块给我的 测试代码好了。测试代码在 /root/nginx-rtmp-module/test/nginx.conf
我把这个测试的nginx.conf 拷贝到 /usr/local/nginx/conf/conf/下 用rtmp.conf命名 不要忘记在conf文件下 在创建个 conf文件哦。。大概的命令就是这个样子了
[root@localhost ~]# cd /usr/local/nginx/conf #进入conf配置文件夹
[root@localhost ~]# mkdir conf #创建conf文件夹 (他的目录应该是 /usr/local/nginx/conf/conf)
[root@localhost ~]# cp /root/nginx-rtmp/test/nginx.conf /usr/local/nginx/conf/conf/rtmp.conf#拷贝文件然后我需要把rtmp.conf文件放到nginx.conf下。
[root@localhost ~]# vi /usr/local/nginx/conf/nginx.conf #编辑nginx.conf
这个时候 要在nginx.conf配置文件里最下面 加入一行代码 include conf/*.conf 这就吧我拷贝的rtmp.conf 放进去了 然后修改这个文件 把除了rtmp{ } 内容外面的东西全部删掉因为起冲突。所以只需要rtmp就够了。
这基本就配置完毕了 。然后启动 nginx服务
[root@localhost ~]# /usr/local/nginx/sbin/nginx #启动nginx服务
这里假设我内网ip 是192.168.0.127 那么流服务器就是 
rtmp://192.168.0.127/myapp
注意 : 这里的myapp 就是rtmp.conf 中 application的值(test中默认的) 
我们可以用 rtmp://192.168.0.127/myapp/test 来推流 这个test其实就是缓存文件什么都可以。
接下来我可以用一个程序软件来测试他  https://ffmpeg.org/来下载 ffmpeg ,接下来将用windows操作系统来进行推流与播放。
ffmpeg -i rtmp://*******(源地址) -c:v copy -c:a copy -f flv -y rtmp://*******(服务器地址) #推流命令
D:\> ffmpeg -i rtmp://live.hkstv.hk.lxdns.com/live/hks -c:v copy -c:a copy -f flv -y rtmp://192.168.0.127/myapp/test
然后另起一个cmd
D:\> ffplay rtmp://192.168.0.127/myapp/test
OK大功告成
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
12:nginx架设 hls 服务器
1,先在http{}里添加一个这个配置信息。
server {
listen 8080;
#HLS配置开始,这个配置为了`客户端`能够以http协议获取HLS的拉流
location /hls {
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
root /usr/local/nginx/html; #因为root指向 所以接受流的时候 实际上是去了/usr/local/nginx/html/hls 这里
  
      expires -1;
        }
}
2,在在nginx.conf 的http上写一个rtmp配置

rtmp {
server {
listen 1935;
        #rtmp流 如推流方式 rtmp://localhost/myapp/test 读流方式也是 rtmp://localhost/myapp/test
        application myapp {
live on;
record off;
}
        #hls流 如推流方式 rtmp://localhost/hls/test 但读流方式则是 http://localhost:8080/hls/test.m3u8
        application hls {
live on;
hls on;
hls_path /usr/local/nginx/html/hls;
hls_fragment 5s;
}
#增加对HLS支持结束
}
}

2,此时 nginx.conf应该是这个样子的。
.....
......
http{ ......  } #http
rtmp{ ...... } #流
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
 

Centos 从零开始 (四)的更多相关文章

  1. Centos 从零开始 (一)

    因为本人也是刚接触 centos 24k纯小白, 所以是从零开始的攻略的 ,可能技术层次理解的不是很深.但这些东西都是无限的测试,之后一步步可行的. 同时我遇到的问题也会不断的刷新在我的微博上. 一. ...

  2. centos从零开始安装elasticSearch

    前言:elasticSearch作为一款优秀的分布式搜索工具,被广泛用在数据搜集和整理的业务中,知名的比如有github就是采用es来精准的搜索几千万行代码,百度也大量应用es做数据爬取分析,本篇博客 ...

  3. Linux学习之CentOS(十四)----磁盘管理之 硬连接与软件连接(转)

    前言 在 Linux 底下的连结档有两种,一种是类似 Windows 的快捷方式功能的文件,可以让你快速的链接到目标文件(或目录),这种是软链接: 另一种则是透过文件系统的 inode 连结来产生新档 ...

  4. linux学习之centos(四):git的安装

    整个流程如下:(参考文章:linux安装git方法) [carsonzhu@localhost 桌面]$ wget https://github.com/git/git/archive/v2.8.3. ...

  5. Centos 从零开始 (二)

    因为我是搞 nodejs的 所以以后会安装一些依赖于node的 比如mongodb数据库等. 6:安装nodejs 安装的时候遇到个小问题.yum install nodejs 报错 说没有这个包.然 ...

  6. ASP.NET Core + Docker + Jenkins + gogs + CentOS 从零开始搭建持续集成

    为什么不用gitlab? 没有采用gitlab,因为gitlab比较吃配置,至少得2核4G的配置.采用go语言开发的gogs来代替,搭建方便(不到10分钟就能安装完成),资源消耗低,功能也比较强大,也 ...

  7. Centos 从零开始 (三)

    8:连接阿里云. 需要用到 ssh指令进行远程登陆 [root@localhost ~]# service sshd start #如果没开启服务的话,需要开启服务. [root@localhost  ...

  8. CentOS 7数据库mysql和mariadb手动安装冲突的问题解决

    由于确定使用mysql,那只有卸载mariadb了. 一.首先查看当前安装的mariadb包 rpm -qa|grep mariadb 本人得到结果是:mariadb-libs-5.5.44-2.el ...

  9. [centos][ntp][administrator] chrony ntp

    以下内容,适用于 CentOS 7 (systemd 体系) 一. 首先,确认你是否启用了 ntp 服务: [root@nlb2-liantiao ~]# timedatectl Local time ...

随机推荐

  1. Performance profile of a typical interior scene

    ------------------------------- Num faces: 7000k+ Num lights: 38 Num textures: 79 Textures on disk: ...

  2. pageadminCMS.Net Framework的安装教程

    很多用户第一次安装PageAdmin建站系统时候会出现这个错误,主要原因:Net Framework是微软的一个系统组件,基本所有windows平台上开发的产品都需要安装Net Framework,除 ...

  3. Ubuntu16.04以root身份登入!

    首先以非root用户身份登入系统. 1,修改root密码:启动shell,随后在shell里面输入命令: sudo passwd root 最后输入root要使用的密码,需要输入两次,这样root密码 ...

  4. Windows server 2008 R2安装MySQL 32位ODBC驱动!

    在Windows server 2008 R2安装MySQL 32位ODBC驱动,总是提示错误,我安装了DOTNET4的库,同时安装了VC2008.VC2012.VC2013的支持库,怎么还不行呢?M ...

  5. depth深度

    du.tree.find ls -li find ./ -inum 1193220 | while read a ;do rm -f $a;done find ./ -size 0b -type f ...

  6. OCP 052最新考试题库和答案收集-34

    34.Which two can be backed up by using RMAN when a database Is open in ARCHIVELOG mode, so that medi ...

  7. Windows 操作系统如何使程序开机自启

    Windows 操作系统如何开机自启 一.前言: 作为一只运维开发,很多时候需要将自己的小工具做开机自启.在 Linux 的世界里,如果你希望一个程序可以开机自启,那么可以在/etc/rc.d/rc. ...

  8. shell中tr的用法

    转自http://blog.csdn.net/zhuying_linux/article/details/6825568 tr(translate缩写)主要用于删除文件中的控制字符,或进行字符转换.语 ...

  9. Eclipse Java SE升级Java EE

    网上教程大多是提供了“http://download.eclipse.org/releases/ganymede/”地址,但是实际更新过程中会报错. 大致查询了一下,很可能是版本不匹配的问题,正确的更 ...

  10. python cookbook

    一 .数据结构 python collections包中 deque :固定长度队列,(例如固定长度的cache什么的) defaultdict:如果每个键值不存在,默认返回值 orderdict:有 ...