Nginx installation - add MP4 playback module

The nginx installation is very simple, but sometimes it is already installed nginx, and the upgrade adds the nginx module function.

Recently, the company asked nginx to add a module that can play MP4, and the installation went smoothly.

1 Install dependencies

yum install -y make zilb-devel openssl-devel pcre-devel libaio libaio-devel

wget http://nginx.org/download/nginx-1.10.3.tar.gz

#Create users and user groups

groupadd www
useradd -s /sbin/nologin -M -g www www

#decompress

tar -zxvf nginx-1.10.3.tar.gz

#Enter the nginx installation directory

cd nginx-1.10.3

#Configure compile and install

./configure --user=www --group=www \
--prefix=/usr/local/nginx \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-http_gzip_static_module \
--with-http_gunzip_module \
--with-file-aio \
--with-http_flv_module \
make && make install

#Enter nginx sbin to start

cd /usr/local/nginx/sbin

./nginx

So far the installation is complete

The following is the addition of MP4 playback function module based on the original nginx

First download nginx_mod_h264_streaming-2.2.7.tar.gz

wget http://h264.code-shop.com/download/nginx_mod_h264_streaming-2.2.7.tar.gz

tar -xvf nginx_mod_h264_streaming-2.2.7.tar.gz

#the point is coming

vim nginx_mod_h264_streaming-2.2.7

NGINX=$(HOME)/nginx-1.10.3/ #Modify your own nginx version here

#vim nginx_mod_h264_streaming-2.2.7/src/ngx_http_streaming_module.c

the following

ALL: Win32

if (r->zero_in_uri)

{

return NGX_DECLINED;

}

change to

/*

ALL: Win32

if (r->zero_in_uri)

{

return NGX_DECLINED;

}

*/

#Then enter the nginx installation directory again

cd nginx-1.10.3

./configure --user=www --group=www
--add-module=/usr/local/src/nginx_mod_h264_streaming-2.2.7 \
--prefix=/usr/local/nginx \
--with-http_mp4_module \
--with-http_flv_module \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-http_gzip_static_module \
--with-http_gunzip_module \
--with-file-aio \
--with-http_flv_module \

#Note that only compilation is not installed here

make

#Modify the nginx configuration file. It is strongly recommended to modify the backup. Here I add the nginx Vhost directly. Add the following server directly under conf.d under nginx conf

server {
listen 80;
server_name 你的域名;
root html;
index index.html index.htm;
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
location ~.(jpg|png|gif)$ {
root /data/www/oul;
}
location ~
.*.mp4$ {
root /data/www/oul;
mp4;
}
}

Pay attention to this key step

back up your

cd /usr/local/nginx/sbin

cp nginx nginx.bak

Copy the newly compiled nginx executable file

cp /root/cd nginx-1.10.3/objs/nginx /usr/local/nginx/sbin/nginx

Find an MP4 video file and put it in the nginx website directory by default under /usr/local/nginx/html

restart nginx

There is a pit, pay attention to modify the root access folder of nginx's vhost, you must restart reload, it does not work! ! !

In addition, if the process of adding other functional modules to nginx is mostly the same, pay attention to make only to compile and not to perform installation backup and the files you want to modify.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324902448&siteId=291194637