nginx configuration to play mp4 format video online

One, install nginx

1. Download the installation package

Download nginx: wget http://nginx.org/download/nginx-1.7.3.tar.gz
unzip the nginx installation package: tar -xzvf nginx-1.7.3.tar.gz
download nginx support online playback plug-in: wget http://h264.code-shop.com/download/nginx_mod_h264_streaming-2.2.7.tar.gz
unzip the plug-in package: tar -xzvf nginx_mod_h264_streaming-2.2.7.tar.gz
download the socket plug-in: wget https://bitbucket.org/nginx-goodies/nginx-sticky-module-ng/get/08a395c66e42.zip
unzip the socket plug-in:unzip nginx-goodies-nginx-sticky-module-ng-08a395c66e42

2. Installation dependencies

yum -y install gcc gcc-c++ automake gd-devel pcre pcre-devel openssl openssl-devel zlib zlib-devel

Two, compile and install

1. Generate MAKEFILE and
enter the nginx installation package path:

 cd /data/nginx-1.7.3

Use configure to configure and compile nginx and check whether the dependencies are met:

./configure --prefix=/data/nginx  --with-http_gzip_static_module --with-http_flv_module --with-http_dav_module  --with-http_stub_status_module --with-http_realip_module --add-module=/data/nginx/nginx-goodies-nginx-sticky-module-ng-08a395c66e42 --add-module=/data/nginx/nginx_mod_h264_streaming-2.2.7

2. Compile and install

make && make install

3. Encountered an error

/data/nginx_mod_h264_streaming-2.2.7/src/ngx_http_streaming_module.c:158: error: ‘ngx_http_request_t’ has no member named ‘zero_in_uri’
make[1]: *** [objs/addon/src/ngx_http_h264_streaming_module.o] Error 1
make[1]: Leaving directory `/usr/local/src/nginx-0.8.54'
报错:
1、make[1]: *** [objs/addon/src/mp4_reader.o] Error 1

Solution:
①Open the file that reported the error

vim /data/nginx_mod_h264_streaming-2.2.7/src/ngx_http_streaming_module.c

②Go to line 158 and comment out the following
Insert picture description here
③Open the Makefile

vim objs/Makefile

④Delete -Werror parameter ⑤Recompile and
Insert picture description hereinstall

meke && make install

Three, change the configuration file

MP4 direct playback settings

worker_processes  1;

events {
    
    
    worker_connections  1024;
}

http {
    
    
        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;
        #文件服务器
        server {
    
    
        listen 82;
        server_name 127.0.0.1;
        charset utf-8,gbk;
        root /data/cloud/video;
        location ~ \.mp4$ {
    
    
            mp4;
        }
        location / {
    
    
            autoindex on;
            autoindex_exact_size on;
            autoindex_localtime on;     
        }
        }
	server {
    
    
        listen 81;
        server_name 127.0.0.1;
        charset utf-8,gbk;
        root /data/cloud/picture;
        location / {
    
    
            autoindex on;
            autoindex_exact_size on;
            autoindex_localtime on;
        }
        }
}

Fourth, start

Enter the sbin path of the nginx installation path

cd sbin

start up

./nginc -c /data/nginx/conf/nginx_file.conf

Guess you like

Origin blog.csdn.net/xiguashixiaoyu/article/details/111950377