1、下载nginx_mod_h264_streaming-2.2.7
2、下载nginx-rtmp-module-dev
3、下载nginx,这边用的版本是1.15.1
4、将这三个文件解压,进入nginx_mod_h264_streaming-2.2.7/src下,将文件ngx_http_streaming_module.c中以下代码注释或删除。
if (r->zero_in_uri)
{
return NGX_DECLINED;
}。
5、进入nginx目录,执行 ./configure --add-module=../nginx_mod_h264_streaming-2.2.7 --with-http_flv_module --with-http_mp4_module --add-module=../nginx-rtmp-module-dev --with-http_ssl_module
6、执行完以上命令后,执行make && make install,nginx将安装在/usr/local/nginx目录下
7、配置文件
rtmp {
server {
listen 1935;
application live {
live on;
record off;
}
application vod {
play /usr/local/nginx/html;
}
}
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 18081;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location ~ \.flv {
root /usr/local/nginx/html;
flv;
}
location ~ \.mp4$ {
root /usr/local/nginx/html;
mp4;
}
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
8、在目录/usr/local/nginx/sbin启动nginx即可