目录
这篇文章主要记录用nginx实现直播服务,通过RTMP推流和通过HTTP-FLV或RTMP拉流,并在页面中播放。
一、环境准备
CentOS Linux release 7.3.1611 (Core) 3.10.0-514.el7.x86_64
nginx1.25
二、安装编译nginx所需的安装包和下载nginx原代码包
#安装编译nginx环境包
yum install gcc -y
yum install pcre pcre-devel -y
yum install openssl openssl-devel -y
yum install wget -y
#下载nginx和nginx-http-flv-module原代码
mkdir -p /opt/backup/docker-build/nginx-flv/nginx-src
cd /opt/backup/docker-build/nginx-flv/nginx-src
wget http://nginx.org/download/nginx-1.25.0.tar.gz
tar -zxf nginx-1.25.0.tar.gz
git clone https://github.com/winshining/nginx-http-flv-module.git
#编译安装,完成后会安装在/usr/local/nginx-flv下
./configure --prefix=/user/local/nginx-flv --with-http_ssl_module --with-http_secure_link_module --add-module=nginx-http-flv-module-master
make
make install
三、nginx配置
#nginx主配置文件 vim /usr/local/nginx-flv/conf/nginx.conf
#user nobody;
worker_processes auto;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
error_log logs/error.log warn;
pid logs/nginx.pid;
events {
worker_connections 10240;
use epoll;
multi_accept on;
}
http {
include mime.types;
default_type application/octet-stream;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 50m;
log_format nginx_json '{ "time": "$time_local", '
'"remote_ip": "$remote_addr", '
'"remote_user": "$remote_user", '
'"domain":"$host", '
'"responsetime":$request_time, '
'"request": "$request", '
'"response": "$status", '
'"bytes": $body_bytes_sent, '
'"referrer": "$http_referer", '
'"upstreamtime":"$upstream_response_time", '
'"upstreamaddr":"$upstream_addr", '
'"x_forwarded_for":"$http_x_forwarded_for", '
'"agent": "$http_user_agent" }';
access_log logs/access.log nginx_json;
sendfile on;
tcp_nopush on;
server_tokens off;
keep

本文详细介绍了如何在CentOS7上配置和安装Nginx,包括编译安装过程、配置Nginx以支持RTMP和HTTP-FLV直播,以及启动和测试推流和拉流服务。此外,还涵盖了摄像头数据采集和查看服务器统计信息的步骤。
最低0.47元/天 解锁文章
3267

被折叠的 条评论
为什么被折叠?



