Day42
作者:孙鹏鹏
归档:课后笔记
时间:2019/4/29
快捷键:
Ctrl + 1 标题1
Ctrl + 2 标题2
Ctrl + 3 标题3
Ctrl + 4 标题4
Ctrl + 5 程序代码
Ctrl + 6 正文
Ctrl + 7 实例1-1
格式说明:
蓝色字体:注释
黄色背景:重要
绿色背景:注意
老男孩教育教学核心思想6重:重目标、重思路、重方法、重实践、重习惯、重总结
学无止境,老男孩教育成就你人生的起点!
联系方式:
网站运维QQ交流群:
Linux 385168604架构师390642196
Python 29215534大数据421358633
官方网站:
http://www.oldboyedu.com
目 录
第一章:
#切换目录
cd /etc/yum.repos.d/
#更新yum源
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
#生成缓存
yum makecache
#下载各种工具
#yum install wget net-tools vim tree htop iftop iotop lrzsz slunzip telnet nmap nc psmisc dos2unix bash-completion nethogs glances -y
#关闭防火墙
#systemctl stop firewalld
#systemctl disable firewalld
![](http://img.e-com-net.com/image/info10/ca34ce126f10487891933886973cd7db.jpg)
#关闭selinux
#setenforce 0
#sed -ri 's#(^SELINUX=).*#\1disabled#g' /etc/selinux/config
#下载git工具
#yum install openssl-devel -y
#yum install pcre-devel -y
#yum install gcc –y
#yum install make -y
#yum install git -y
#!/bin/bash
#切换目录
cd /usr/local
#安装git模块
git clone git://github.com/arut/nginx-rtmp-module.git
#安装nginx包
wget http://nginx.org/download/nginx-1.15.0.tar.gz
#压缩nginx包
tar zxf nginx-1.15.0.tar.gz
#切换目录
cd /usr/local/nginx-1.15.0
#缓存压缩包
/usr/local/nginx-1.15.0/configure --with-http_ssl_module--add-module=../nginx-rtmp-module
![](http://img.e-com-net.com/image/info10/50b81096327f49bb9503352945457b05.jpg)
#编译源码并安装
#make
#make install
#开启nginx
/usr/local/nginx/sbin/nginx
/usr/local/nginx/sbin/nginx
#切换目录
cd /usr/local/nginx/conf
#编辑nginx.conf
vimnginx.conf
rtmp{
server{
listen 1935;
chunk_size 5000;
application hls{
live on;
hls on;
record off;
hls_path /usr/local/nginx/html/hls;
hls_fragment 3s;
}
}
}
#切换目录并且查看切片
cd/usr/local/nginx/html
cd/usr/local/nginx/html/hls
ls
#编辑play.html
vimplay.html
![](http://img.e-com-net.com/image/info10/9d47e43bee9c49c898876ca144638782.jpg)
PC 端播放 HLS(.m3u8
) 视频
借助 video.js 和 videojs-contrib-hls
由于 videojs-contrib-hls 需要通过 XHR 来获取解析 m3u8 文件, 因此会遭遇跨域问题, 请设置浏览器运行跨域
// XMLHttpRequest cannot load http://xxx/video.m3u8. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://192.168.198.98:8000' is therefore not allowed access.
// 由于 videojs-contrib-hls 需要通过 XHR 来获取解析 m3u8 文件, 因此会遭遇跨域问题, 请设置浏览器运行跨域
var player = videojs('hls-video');
player.play();
#直播源更换后
/usr/local/nginx/sbin/nginx-s stop
/usr/local/nginx/sbin/nginx-c /usr/local/nginx/conf/nginx.conf
/usr/local/nginx/sbin/nginx
#完事后网页可查看
http://10.0.0.111/play.html