nginx编译安装

本文介绍了如何自定义编译Nginx,包括配置选项如Luajit、SSL模块,以及添加RTMP、ngx_cache_purge、nginx_upstream_check_module等多个模块。同时,展示了Nginx的rtmp配置,包括日志格式、http服务器配置和lua脚本的使用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

./configure
–prefix=/opt/openresty
–with-luajit
–with-http_ssl_module
–user=root
–group=root
–with-http_realip_module
–add-module=./bundle/ngx_cache_purge-2.3/
–add-module=./bundle/nginx_upstream_check_module-0.3.0/
–add-module=./bundle/nginx-rtmp-module
–with-http_xslt_module
–with-http_stub_status_module
–with-http_gzip_static_module
–with-http_flv_module
–with-http_perl_module
–with-mail

user root;
worker_processes 1;
#daemon off;
#error_log
logs/error.log;
#error_log
logs/error.log notice;
#error_log
logs/error.log info;
#pid
logs/nginx.pid;
events {
worker_connections 1024;
}

rtmp {
#设置rtmp的日志记录, 该记录只有在直播流结束后过显示在日志里, 不能connect的阶段记录, 该问题暂未解决
log_format rtmp_main ' r e m o t e a d d r [ remote_addr [ remoteaddr[time_local] c o m m a n d " command " command"app" “ n a m e " " name" " name""args” ’ '$bytes_received b y t e s s e n t " bytes_sent " bytessent"pageurl" " f l a s h v e r " ( flashver" ( flashver"(session_readable_time) $connection $session_time ';

access_log logs/rtmp_access.log rtmp_main;        

server{        
	listen 1935;    
	ack_window 5000;
	#窗口大小    
	chunk_size 1024;        
	application live {            
		live on;            
		wait_key on;            
		drop_idle_publisher 10s;            
		wait_video on;    
		interleave on;sync 10ms;        
	}    
}

}

http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - r e m o t e u s e r [ remote_user [ remoteuser[time_local] “KaTeX parse error: Double superscript at position 12: request" ' '̲status b o d y b y t e s s e n t " body_bytes_sent " bodybytessent"http_referer” ’ ‘“ h t t p u s e r a g e n t " " http_user_agent" " httpuseragent""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;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location /stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
#将stat.xsl文件放置到安装目录里的html文件夹中
}
location /stat.xsl {
root html;
}
location /nclients {
proxy_pass http://127.0.0.1/stat;
#将nclients.xsl文件放置到安装目录里的html文件夹中, nclients.xsl具体内容在下面
xslt_stylesheet html/nclients.xsl app=‘ a r g a p p ′ n a m e = ′ arg_app' name=' argappname=arg_name’;
add_header Refresh “3;$request_uri”;
}
location /test{
content_by_lua_file conf/lua/test.lua;
#测试lua执行的helloworld
}
location /control{
rtmp_control all;
#rtmp的http控制api生效
}
}
}

<xsl:stylesheet version=“1.0” xmlns:xsl=“http://www.w3.org/1999/XSL/Transform”>
<xsl:output method=“html”/>
<xsl:param name=“app”/>
<xsl:param name=“name”/>
<xsl:template match="/">
<xsl:value-of select=“count(//application[name= a p p ] / l i v e / s t r e a m [ n a m e = app]/live/stream[name= app]/live/stream[name=name]/client[not(publishing) and flashver])”/>
</xsl:template>
</xsl:stylesheet>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值