一区二区三区在线-一区二区三区亚洲视频-一区二区三区亚洲-一区二区三区午夜-一区二区三区四区在线视频-一区二区三区四区在线免费观看

服務器之家:專注于服務器技術及軟件下載分享
分類導航

云服務器|WEB服務器|FTP服務器|郵件服務器|虛擬主機|服務器安全|DNS服務器|服務器知識|Nginx|IIS|Tomcat|

服務器之家 - 服務器技術 - Nginx - 使用nginx搭建點播和直播流媒體服務器的方法步驟

使用nginx搭建點播和直播流媒體服務器的方法步驟

2019-12-14 16:20限albert Nginx

本篇文章主要介紹了使用nginx搭建點播和直播流媒體服務器的方法步驟,小編覺得挺不錯的,現在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧

環境   centos7 nginx

1 安裝nginx依賴包 yum install gcc gcc-c++ openssl-devel zlib-devel pcre pcre-devel yamdi

2.下載解壓nginx_mod_h264_streaming,讓nginx支持flv,mp4流播放   wget http://h264.code-shop.com/download/nginx_mod_h264_streaming-2.2.7.tar.gz 解壓后需要修改src目錄下的ngx_http
_streaming_module.c文件,將r->zero_in_uri所在的if語句注釋掉

3.下載解壓nginx-rtmp-module,讓nginx支持rtmp/hls協議,wegt -o nginx-rtmp-module.zip  https://github.com/arut/nginx-rtmp-module/archive/master.zip

4下載清除緩存的模塊 wget -Ongx_cache_purge.zip     https://github.com/FRiCKLE/ngx_cache_purge/archive/master.zip

5.下載nginx  wget http://nginx.org/download/nginx-1.9.0.tar.gz

6 .進入nginx的安裝目錄下 執行以下命令./configure --prefix=/usr/local/nginx/--add-module=../nginx-rtmp-module-master --add-module=../ngx_cache_purge-master--add-module=../nginx_mod_h264_streaming-2.2.7 --with-http_stub_status_module--with-http_ssl_module --with-http_sub_module --with-http_gzip_static_module--with-http_flv_module

7. 執行以下命令編譯文件make && make install ,并修改nginx安裝目錄下的objs下的Makefile 刪除-Werror

9. 修改nginx.conf

10. 通過yum 停止firewalld防火墻并卸載,然后安裝iptables-services修改/etc/sysconfig/iptables文件夾放行80端口

11.nginx 配置如下:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#使用的用戶和組
#user nobody;
#指定工作衍生的進程數,為cpu的核心數總和
worker_processes 2;
#指定錯誤日志的存放路徑 日志記錄級別[debug,info,notice,warn,error,crit]
error_log  /usr/local/nginx/logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#指定pid存放的路徑
pid    /usr/local/nginx/logs/nginx.pid;
events {
  #使用的網絡I/O模型,linux系統推薦是epoll而freeBSD是kqueue
  use epoll;
  #允許的連接數,最大的高并發連接數為worker_processes*worker_connections
  worker_connections 51200;
}
 
rtmp {
 server {
  listen 1935;
  chunk_size 4096;
  application live {
   live on;
   record off;
  }
  #application live2 {
   #live on;
   #record off;
  #}
  # video on demand
  application media {
   play /usr/local/nginx/html/;
  }
  #application vod_http {
   #play http://192.168.31.185/vod;
  #}
  application hls {
   live on;
   hls on;
   hls_path /tmp/hls;
  }
 }
}
 
http {
  include    mime.types;
  default_type application/octet-stream;
  #
  #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  #         '$status $body_bytes_sent "$http_referer" '
  #         '"$http_user_agent" "$http_x_forwarded_for"';
 
  #access_log logs/access.log main;
  sendfile    on;
  #tcp_nopush   on;
  #keepalive_timeout 0;
  keepalive_timeout 65;
  gzip on;
  server {
    listen    80;
    server_name localhost;
    #charset koi8-r;
    #access_log logs/host.access.log main;
    location / {
      root  html;
      index index.html index.htm;
    }
 
location ~ \.flv$ {
  root /usr/local/nginx/html/media/
  flv;
}
location ~ \.mp4$ {
  root /usr/local/nginx/html/media/;
  mp4;
}
 
location /stat {
   rtmp_stat all;
   # Use this stylesheet to view XML as web page
   # in browser
   rtmp_stat_stylesheet stat.xsl;
 }
 location /stat.xsl {
   # XML stylesheet to view RTMP stats.
   # Copy stat.xsl wherever you want
   # and put the full directory path here
   root /path/to/stat.xsl/;
 }
 location /hls {
   # Serve HLS fragments
   types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
   }
   root /tmp;
   add_header Cache-Control no-cache;
 }
 location /dash {
   # Serve DASH fragments
   root /tmp;
   add_header Cache-Control no-cache;
 }
 
    #error_page 404       /404.html;
    # redirect server error pages to the static page /50x.html
    #
    error_page  500 502 503 504 /50x.html;
    location = /50x.html {
      root  html;
    }
 
 
    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #  proxy_pass  http://127.0.0.1;
    #}
 
    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #  root      html;
    #  fastcgi_pass  127.0.0.1:9000;
    #  fastcgi_index index.php;
    #  fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
    #  include    fastcgi_params;
    #}
 
    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #  deny all;
    #}
  }
 
  # another virtual host using mix of IP-, name-, and port-based configuration
  #
  #server {
  #  listen    8000;
  #  listen    somename:8080;
  #  server_name somename alias another.alias;
 
  #  location / {
  #    root  html;
  #    index index.html index.htm;
  #  }
  #}
 
  # HTTPS server
  #
  #server {
  #  listen    443 ssl;
  #  server_name localhost;
 
  #  ssl_certificate   cert.pem;
  #  ssl_certificate_key cert.key;
 
  #  ssl_session_cache  shared:SSL:1m;
  #  ssl_session_timeout 5m;
 
  #  ssl_ciphers HIGH:!aNULL:!MD5;
  #  ssl_prefer_server_ciphers on;
 
  #  location / {
  #    root  html;
  #    index index.html index.htm;
  #  }
  #}
}

12. 輸入xxx.xxx.xxx.xxx/*.mp4/*.flv就能播放視頻了

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持服務器之家。

原文鏈接:http://blog.csdn.net/u011922760/article/details/52650553

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 国产欧美日韩图片一区二区 | 青草草产国视频 | 398av影院视频在线 | 亚洲欧美日韩精品久久亚洲区 | 国产成人愉拍免费视频 | 成人免费视频播放 | 好男人在线观看免费高清2019韩剧 | 无码一区国产欧美在线资源 | 91传媒在线观看 | 国产精品久久久99 | 操老逼| 国产一区二区视频在线播放 | 236zz宅宅最新伦理 | 9l桃色| 性姿势女人嗷嗷叫图片 | 成人高清网站 | 国产良心大作白丝精厕 | 免费观看在线 | 丁香婷婷在线视频 | 9191视频 | 欧美性bbbbbxxxxxxx | 99r在线播放 | 四虎最新网址在线观看 | 亚洲国产精品自在自线观看 | 欧美男同videos| 日韩一区二区三区在线 | 国模一区二区三区视频一 | 欧美亚洲国产另类在线观看 | 扒开老女人 | 国产成人99精品免费观看 | 日剧整部剧护妻狂魔免费观看全集 | 久久中文骚妇内射 | 韩国最新三级网站在线播放 | 国产精品亚洲精品日韩已方 | 日韩理论在线观看 | 人妖三级 | 国产第一页在线视频 | 青草久久精品亚洲综合专区 | 色琪琪久久草在线视频 | 皇上好大好硬好涨好深好爽 | 肉肉小说在线阅读 |