In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to use nginx to build VOD and live streaming servers. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
Environment centos7 nginx
1 install the nginx dependency package yum install gcc gcc-c++ openssl-devel zlib-devel pcre pcre-devel yamdi
two。 Download and decompress nginx_mod_h364_streaming to make nginx support flv. After MP4 stream playback wget http://h364.code-shop.com/download/nginx_mod_h364_streaming-2.2.7.tar.gz is decompressed, you need to modify ngx_http in src directory.
_ streaming_module.c file to comment out the if statement where r-> zero_in_uri is located
3. Download and decompress nginx-rtmp-module and let nginx support rtmp/hls protocol, wegt-o nginx-rtmp-module.zip https://github.com/arut/nginx-rtmp-module/archive/master.zip
Download wget-Ongx_cache_purge.zip https://github.com/FRiCKLE/ngx_cache_purge/archive/master.zip module to clear the cache
5. Download nginx wget http://nginx.org/download/nginx-1.9.0.tar.gz
6. Go to the nginx installation directory and execute the following command. / configure-- prefix=/usr/local/nginx/--add-module=../nginx-rtmp-module-master-- add-module=../ngx_cache_purge-master--add-module=../nginx_mod_h364_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. Execute the following command to compile the file make & & make install, and modify the Makefile under objs under the nginx installation directory to delete-Werror
9. Modify nginx.conf
10. Stop firewalld Firewall via yum and uninstall, then install iptables-services modify / etc/sysconfig/iptables folder to release port 80
The 11.nginx configuration is as follows:
# users and groups # user nobody;# specifies the number of processes derived from work, for the total number of cores of cpu and worker_processes 2 worker_processes # specify the path to store the error log logging level [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 # specify the path to pid storage pid / usr/local/nginx/logs/nginx.pid;events {# use the network I chunk_size O model, linux system recommends epoll and freeBSD is the number of connections allowed by kqueue use epoll; #, and the maximum number of highly concurrent connections is 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 m3u8scape videoswap 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 50x.html 80 # location ~\ .php$ {# proxy_pass #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1 pass the PHP scripts to FastCGI server listening on 9000 # # location ~\. Php$ {# root html; # fastcgi_pass 127.0.0.1 php$ 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 Higg / ssl_session_timeout 5m; # ssl_prefer_server_ciphers on; # location / {# root html # index index.html index.htm; #} #}}
twelve。 Enter xxx.xxx.xxx.xxx/*.mp4/*.flv to play the video.
This is the end of the article on "how to use nginx to build a VOD and live streaming server". I hope the above content can be helpful to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.