最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

使用nginx搭建點(diǎn)播和直播流媒體服務(wù)器的方法步驟

 更新時(shí)間:2018年03月21日 09:07:36   作者:限albert  
本篇文章主要介紹了使用nginx搭建點(diǎn)播和直播流媒體服務(wù)器的方法步驟,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧

環(huán)境   centos7 nginx

1 安裝nginx依賴(lài)包 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語(yǔ)句注釋掉

3.下載解壓nginx-rtmp-module,讓nginx支持rtmp/hls協(xié)議,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 .進(jìn)入nginx的安裝目錄下 執(zhí)行以下命令./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. 執(zhí)行以下命令編譯文件make && make install ,并修改nginx安裝目錄下的objs下的Makefile 刪除-Werror

9. 修改nginx.conf

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

11.nginx 配置如下:

#使用的用戶和組
#user nobody;
#指定工作衍生的進(jìn)程數(shù),為cpu的核心數(shù)總和
worker_processes 2;
#指定錯(cuò)誤日志的存放路徑 日志記錄級(jí)別[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 {
  #使用的網(wǎng)絡(luò)I/O模型,linux系統(tǒng)推薦是epoll而freeBSD是kqueue
  use epoll;
  #允許的連接數(shù),最大的高并發(fā)連接數(shù)為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就能播放視頻了

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Nginx服務(wù)器中的location配置詳解

    Nginx服務(wù)器中的location配置詳解

    這篇文章主要介紹了Nginx服務(wù)器中的location配置詳解,包括location的匹配順序等基本概念,需要的朋友可以參考下
    2015-08-08
  • 基于nginx反向代理獲取用戶真實(shí)Ip地址詳解

    基于nginx反向代理獲取用戶真實(shí)Ip地址詳解

    我們?cè)L問(wèn)互聯(lián)網(wǎng)上的服務(wù)時(shí),大多數(shù)時(shí)客戶端并不是直接訪問(wèn)到服務(wù)端的,而是客戶端首先請(qǐng)求到反向代理,反向代理再轉(zhuǎn)發(fā)到服務(wù)端實(shí)現(xiàn)服務(wù)訪問(wèn),這篇文章主要給大家介紹了關(guān)于如何基于nginx反向代理獲取用戶真實(shí)Ip地址的相關(guān)資料,需要的朋友可以參考下
    2022-03-03
  • 解讀nginx負(fù)載均衡的5種策略

    解讀nginx負(fù)載均衡的5種策略

    這篇文章主要介紹了解讀nginx負(fù)載均衡的5種策略,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-07-07
  • CentOS 7.3.1611編譯安裝Nginx1.10.3+MySQL5.7.16+PHP7.1.2

    CentOS 7.3.1611編譯安裝Nginx1.10.3+MySQL5.7.16+PHP7.1.2

    這篇文章主要介紹了CentOS 7.3.1611編譯安裝Nginx1.10.3+MySQL5.7.16+PHP7.1.2,需要的朋友可以參考下
    2018-01-01
  • Nginx配置PHP的Yii與CakePHP框架的rewrite規(guī)則示例

    Nginx配置PHP的Yii與CakePHP框架的rewrite規(guī)則示例

    這篇文章主要介紹了Nginx配置PHP的Yii與CakePHP框架的rewrite規(guī)則示例,是這兩款高人氣框架使用Nginx的關(guān)鍵配置點(diǎn),需要的朋友可以參考下
    2016-01-01
  • Nginx各個(gè)模塊的配置及常用配置選項(xiàng)

    Nginx各個(gè)模塊的配置及常用配置選項(xiàng)

    本文總結(jié)了Nginx常用配置選項(xiàng),包括url匹配優(yōu)先級(jí)、請(qǐng)求轉(zhuǎn)發(fā)、日志配置、超時(shí)配置、靜態(tài)文件處理以及負(fù)載均衡的各項(xiàng)算法,對(duì)Nginx?模塊配置相關(guān)知識(shí)感興趣的朋友一起看看吧
    2022-01-01
  • nginx配置ssl證書(shū)實(shí)現(xiàn)https訪問(wèn)的示例

    nginx配置ssl證書(shū)實(shí)現(xiàn)https訪問(wèn)的示例

    這篇文章主要介紹了nginx配置ssl證書(shū)實(shí)現(xiàn)https訪問(wèn)的示例,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2018-03-03
  • nginx配置多個(gè)虛擬主機(jī)vhost的方法示例

    nginx配置多個(gè)虛擬主機(jī)vhost的方法示例

    這篇文章主要介紹了nginx配置多個(gè)虛擬主機(jī)vhost的方法示例,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2018-10-10
  • win10上安裝nginx的方法步驟

    win10上安裝nginx的方法步驟

    這篇文章主要介紹了win10上安裝nginx的方法步驟,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-10-10
  • Nginx啟用proxy_cache緩存的方法

    Nginx啟用proxy_cache緩存的方法

    本篇文章主要介紹了Nginx啟用proxy_cache緩存的方法,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2018-03-03

最新評(píng)論

铜山县| 乌恰县| 潮州市| 宜州市| 兰州市| 德江县| 涿鹿县| 绿春县| 安陆市| 上高县| 绵阳市| 壤塘县| 竹北市| 常熟市| 淳安县| 壶关县| 高雄市| 新龙县| 兴山县| 三门峡市| 剑河县| 静海县| 六盘水市| 遂宁市| 睢宁县| 曲松县| 湖北省| 察隅县| 阿鲁科尔沁旗| 平果县| 海口市| 丹寨县| 本溪市| 安阳县| 蒙阴县| 镇赉县| 灵川县| 南京市| 潼关县| 葵青区| 德清县|