RTMP推流服务器nginx在linux上的编译部署

RTMP(Real-Time Messaging Protocol)推流确实需要服务器支持‌。RTMP推流服务器的主要功能是接收来自推流客户端的数据流,对其进行处理和转发。服务器会根据RTMP协议与客户端建立连接,处理推流数据(如转码、录制等),然后将处理后的数据流发送给观看客户端。RTMP推流服务器的好处在于支持高性能、低延迟的实时数据传输,广泛应用于在线直播、视频会议、实时监控等场景‌1。

RTMP推流服务器的具体作用和好处

  1. 接收和处理推流数据‌:RTMP推流服务器接收来自推流客户端的音视频数据流,对其进行处理和转发。服务器可以对推流数据进行转码、录制等操作,确保数据的稳定传输‌1。
  2. 低延迟和高性能传输‌:RTMP协议支持高性能、低延迟的实时数据传输,能够满足高并发、低延迟的实时数据传输需求,提供稳定可靠的服务‌1。
  3. 多种推流客户端支持‌:RTMP推流服务器支持多种推流客户端,如各种直播软件和硬件设备,增加了其应用的广泛性和灵活性‌

实现RTMP推流服务:Nginx部署,并带入ginx-http-flv-module

采集板子上的摄像头视频流,使用gstreamer/ffmpeg进行RTMP推流到板子上的nginx服务器(nginx通过rtmp模块提供rtmp服务),然后在同个局域网内使用vlc播放器(或其他客户端)从nginx服务器获取该实时视频流。
nginx-http-flv-module 是一个基于 nginx-rtmp-module 开发的媒体流服务器模块。该项目的主要编程语言是C语言,它扩展了 nginx-rtmp-module 的功能,使其支持HTTP-FLV协议,从而提供更高效的流媒体传输服务。
 

1.configure failed问题:
./configure: error: C compiler /opt/bstos/linux-23/sysroots/x86_64-bstsdk-linux/usr/bin/aarch64-bst-linux/aarch64-bst-linux-gcc is not found

congigure文件增加:
CC=gcc
export CC

2,.configure failed问题,安装 pcre
apt update
apt install libpcre3 libpcre3-dev

3,.configure failed问题,安装zlib
apt-get update
apt-get install zlib1g zlib1g-dev


4,.configure:ok
根据configuration自动生成ngx_auto_config.h功能配置文件,功能宏的开关
cd nginx-1.18.0
./configure --prefix=/usr/local/nginx --with-threads --with-file-aio --add-module=../nginx-http-flv-module --with-http_ssl_module --with-http_flv_module --with-pcre=/path/to/pcre --with-zlib=/path/to/zlib --with-openssl=/path/to/openssl --with-ld-opt="-static" --with-http_dav_module --with-http_degradation_module  --with-http_realip_module --with-http_stub_status_module


Configuration summary
  + using threads
  + using PCRE library: /path/to/pcre
  + using OpenSSL library: /path/to/openssl
  + using zlib library: /path/to/zlib

  nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx modules path: "/usr/local/nginx/modules"
  nginx configuration prefix: "/usr/local/nginx/conf"
  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
  nginx pid file: "/usr/local/nginx/logs/nginx.pid"
  nginx error log file: "/usr/local/nginx/logs/error.log"
  nginx http access log file: "/usr/local/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"

5,Linking, undefined reference to `ngx_rtmp_dash_module'
   
  解决方案: 增加nginx-http-flv-module\dash的编译

6,Linking, undefined reference to `crypt_r'
[100%] Linking C executable nginx
/opt/bstos/linux-23/sysroots/x86_64-bstsdk-linux/usr/libexec/aarch64-bst-linux/gcc/aarch64-bst-linux/8.3.0/real-ld: CMakeFiles/nginx.dir/nginx-1.18.0/src/os/unix/ngx_user.c.o: in function `ngx_libc_crypt':
/home/C882Dev_2351/C882_AP/app/nginx/nginx-1.18.0/src/os/unix/ngx_user.c:25: undefined reference to `crypt_r'
collect2: error: ld returned 1 exit status
CMakeFiles/nginx.dir/build.make:2866: recipe for target 'nginx' failed
make[2]: *** [nginx] Error 1
CMakeFiles/Makefile2:94: recipe for target 'CMakeFiles/nginx.dir/all' failed
make[1]: *** [CMakeFiles/nginx.dir/all] Error 2
Makefile:102: recipe for target 'all' failed
make: *** [all] Error 2

解决方案:
增加: -lcrypt
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --sysroot=${CMAKE_SYSROOT} -O0 -std=c++17 -s -lcrypt")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --sysroot=${CMAKE_SYSROOT} -I${OPENSSL_INCLUDE_DIR} -O2 -Wall -Werror -g -lcrypt")

7,link & Built target nginx OK
[ 93%] Building C object CMakeFiles/nginx_http_flv.dir/nginx-http-flv-module/ngx_rtmp_netcall_module.c.o
[ 94%] Building C object CMakeFiles/nginx_http_flv.dir/nginx-http-flv-module/ngx_rtmp_notify_module.c.o
[ 94%] Building C object CMakeFiles/nginx_http_flv.dir/nginx-http-flv-module/ngx_rtmp_parse.c.o
[ 95%] Building C object CMakeFiles/nginx_http_flv.dir/nginx-http-flv-module/ngx_rtmp_play_module.c.o
[ 95%] Building C object CMakeFiles/nginx_http_flv.dir/nginx-http-flv-module/ngx_rtmp_proxy_protocol.c.o
[ 96%] Building C object CMakeFiles/nginx_http_flv.dir/nginx-http-flv-module/ngx_rtmp_receive.c.o
[ 96%] Building C object CMakeFiles/nginx_http_flv.dir/nginx-http-flv-module/ngx_rtmp_record_module.c.o
[ 97%] Building C object CMakeFiles/nginx_http_flv.dir/nginx-http-flv-module/ngx_rtmp_relay_module.c.o
[ 97%] Building C object CMakeFiles/nginx_http_flv.dir/nginx-http-flv-module/ngx_rtmp_send.c.o
[ 98%] Building C object CMakeFiles/nginx_http_flv.dir/nginx-http-flv-module/ngx_rtmp_shared.c.o
[ 98%] Building C object CMakeFiles/nginx_http_flv.dir/nginx-http-flv-module/ngx_rtmp_stat_module.c.o
[ 99%] Building C object CMakeFiles/nginx_http_flv.dir/nginx-http-flv-module/ngx_rtmp_variables.c.o
[100%] Linking C executable nginx_http_flv
[100%] Built target nginx_http_flv

nginx 编译参数:

./configure --prefix=/usr/local/nginx --with-threads --with-file-aio --add-module=../nginx-http-flv-module --with-http_ssl_module --with-http_flv_module --with-pcre=/path/to/pcre --with-zlib=/path/to/zlib --with-openssl=/path/to/openssl --with-ld-opt="-static" --with-http_dav_module --with-http_degradation_module  --with-http_realip_module --with-http_stub_status_module


--prefix=PATH    指向安装目录
--sbin-path=PATH    指向(执行)程序文件
--conf-path=PATH    指向配置文件(nginx.conf)
--error-log-path=PATH    指向错误日志目录
--pid-path=PATH        指向pid文件(nginx.pid)
--lock-path=PATH    指向lock文件(nginx.lock)(安装文件锁定,防止安装文件被别人利用,或自己误操作。)        

--user=USER         指定程序运行时的非特权用户
--group=GROUP        指定程序运行时的非特权用户组
                    
--builddir=DIR        指向编译目录

--with-select_module        启用select模块支持(一种轮询模式,不推荐在高载环境下使用)禁用:--without-select_module
--without-select_module        禁用:--without-select_module
--with-poll_module            启用poll模块支持(功能与select相同,与select特性相同,为一种轮询模式,不推荐在高载环境下使用)
--without-poll_module        禁用:--without-select_module
    
--with-threads                启用线程池支持

--with-file-aio                启用file aio支持(一种APL文件传输格式)
--with-ipv6                    启用ipv6支持

--with-http_ssl_module        启用ngx_http_ssl_module支持(使支持https请求,需已安装openssl)
--with-http_v2_module         
--with-http_realip_module    启用ngx_http_realip_module支持(这个模块允许从请求标头更改客户端的IP地址值,默认为关)
--with-http_addition_module    启用ngx_http_addition_module支持(作为一个输出过滤器,支持不完全缓冲,分部分响应请求)
--with-http_xslt_module        启用ngx_http_xslt_module支持(过滤转换XML请求)
--with-http_image_filter_module    启用ngx_http_image_filter_module支持(传输JPEG/GIF/PNG 图片的一个过滤器)(默认为不启用。gd库要用到)
--with-http_geoip_module    启用ngx_http_geoip_module支持(该模块创建基于与MaxMind GeoIP二进制文件相配的客户端IP地址的ngx_http_geoip_module变量)
--with-http_sub_module        启用ngx_http_sub_module支持(允许用一些其他文本替换nginx响应中的一些文本)
--with-http_dav_module        启用ngx_http_dav_module支持(增加PUT,DELETE,MKCOL:创建集合,COPY和MOVE方法)默认情况下为关闭,需编译开启
--with-http_flv_module        启用ngx_http_flv_module支持(提供寻求内存使用基于时间的偏移量文件)
--with-http_mp4_module        
--with-http_gunzip_module    
--with-http_gzip_static_module        启用ngx_http_gzip_static_module支持(在线实时压缩输出数据流)
--with-http_auth_request_module        
--with-http_random_index_module        启用ngx_http_random_index_module支持(从目录中随机挑选一个目录索引)
--with-http_secure_link_module        启用ngx_http_secure_link_module支持(计算和检查要求所需的安全链接网址)
--with-http_degradation_module        启用ngx_http_degradation_module支持(允许在内存不足的情况下返回204或444码)
--with-http_slice_module            
--with-http_stub_status_module        启用ngx_http_stub_status_module支持(获取nginx自上次启动以来的工作状态)

--without-http_charset_module        禁用ngx_http_charset_module支持(重新编码web页面,但只能是一个方向--服务器端到客户端,并且只有一个字节的编码可以被重新编码)
--without-http_gzip_module            禁用ngx_http_gzip_module支持(该模块同-with-http_gzip_static_module功能一样)
--without-http_ssi_module            禁用ngx_http_ssi_module支持(该模块提供了一个在输入端处理处理服务器包含文件(SSI)的过滤器,目前支持SSI命令的列表是不完整的)
--without-http_userid_module        禁用ngx_http_userid_module支持(该模块用来处理用来确定客户端后续请求的cookies)
--without-http_access_module        禁用ngx_http_access_module支持(该模块提供了一个简单的基于主机的访问控制。允许/拒绝基于ip地址)
--without-http_auth_basic_module    禁用ngx_http_auth_basic_module(该模块是可以使用用户名和密码基于http基本认证方法来保护你的站点或其部分内容)
--without-http_autoindex_module        禁用disable ngx_http_autoindex_module支持(该模块用于自动生成目录列表,只在ngx_http_index_module模块未找到索引文件时发出请求。)
--without-http_geo_module            禁用ngx_http_geo_module支持(创建一些变量,其值依赖于客户端的IP地址)
--without-http_map_module            禁用ngx_http_map_module支持(使用任意的键/值对设置配置变量)
--without-http_split_clients_module    禁用ngx_http_split_clients_module支持(该模块用来基于某些条件划分用户。条件如:ip地址、报头、cookies等等)
--without-http_referer_module        禁用disable ngx_http_referer_module支持(该模块用来过滤请求,拒绝报头中Referer值不正确的请求)
--without-http_rewrite_module        禁用ngx_http_rewrite_module支持(该模块允许使用正则表达式改变URI,并且根据变量来转向以及选择配置。
如果在server级别设置该选项,那么他们将在 location之前生效。如果在location还有更进一步的重写规则,location部分的规则依然会被执行。
如果这个URI重写是因为location部分的规则造成的,那么 location部分会再次被执行作为新的URI。 这个循环会执行10次,然后Nginx会返回一个500错误。)
--without-http_proxy_module            禁用ngx_http_proxy_module支持(有关代理服务器)
--without-http_fastcgi_module        禁用ngx_http_fastcgi_module支持(该模块允许Nginx 与FastCGI 进程交互,并通过传递参数来控制FastCGI 进程工作。 )FastCGI一个常驻型的公共网关接口。
--without-http_uwsgi_module            禁用ngx_http_uwsgi_module支持(该模块用来医用uwsgi协议,uWSGI服务器相关)
--without-http_scgi_module            禁用ngx_http_scgi_module支持(该模块用来启用SCGI协议支持,SCGI协议是CGI协议的替代。它是一种应用程序与HTTP服务接口标准。它有些像FastCGI但他的设计 更容易实现。)
--without-http_memcached_module        禁用ngx_http_memcached_module支持(该模块用来提供简单的缓存,以提高系统效率)
--without-http_limit_conn_module    禁用ngx_http_limit_zone_module支持(该模块可以针对条件,进行会话的并发连接数控制)
--without-http_limit_req_module        禁用ngx_http_limit_req_module支持(该模块允许你对于一个地址进行请求数量的限制用一个给定的session或一个特定的事件)
--without-http_empty_gif_module        禁用ngx_http_empty_gif_module支持(该模块在内存中常驻了一个1*1的透明GIF图像,可以被非常快速的调用)
--without-http_browser_module        禁用ngx_http_browser_module支持(该模块用来创建依赖于请求报头的值。如果浏览器为modern ,则$modern_browser等于modern_browser_value指令分配的值;
如 果浏览器为old,则$ancient_browser等于 ancient_browser_value指令分配的值;如果浏览器为 MSIE中的任意版本,则 $msie等于1)
--without-http_upstream_hash_module        
--without-http_upstream_ip_hash_module        禁用ngx_http_upstream_ip_hash_module支持(该模块用于简单的负载均衡)
--without-http_upstream_least_conn_module    
--without-http_upstream_keepalive_module    
--without-http_upstream_zone_module

--with-http_perl_module                    启用ngx_http_perl_module支持(该模块使nginx可以直接使用perl或通过ssi调用perl)
--with-perl_modules_path=PATH            设定perl模块路径
--with-perl=PATH                        设定perl库文件路径
--http-log-path=PATH                    设定access log路径
--http-client-body-temp-path=PATH        设定http客户端请求临时文件路径
--http-proxy-temp-path=PATH                设定http代理临时文件路径
--http-fastcgi-temp-path=PATH            设定http fastcgi临时文件路径
--http-uwsgi-temp-path=PATH                设定http uwsgi临时文件路径
--http-scgi-temp-path=PATH                设定http scgi临时文件路径

--without-http                            禁用http server功能
--without-http-cache                    禁用http cache功能
    
--with-mail                                启用POP3/IMAP4/SMTP代理模块支持
--with-mail_ssl_module                    启用ngx_mail_ssl_module支持
--without-mail_pop3_module                禁用pop3协议
--without-mail_imap_module                禁用imap协议
--without-mail_smtp_module                禁用smtp协议

--with-stream                            
--with-stream_ssl_module
--without-stream_limit_conn_module
--without-stream_access_module
--without-stream_upstream_hash_module
--without-stream_upstream_least_conn_module
--without-stream_upstream_zone_module
--with-google_perftools_module            启用ngx_google_perftools_module支持(调试用,剖析程序性能瓶颈)
--with-cpp_test_module                    启用ngx_cpp_test_module支持

--add-module=PATH            启用外部模块支持

--with-cc=PATH                指向C编译器路径
--with-cpp=PATH                指向C预处理路径
--with-cc-opt=OPTIONS        设置C编译器参数
--with-ld-opt=OPTIONS        设置连接文件参数
--with-cpu-opt=CPU            指定编译的CPU,可用的值为: pentium, pentiumpro, pentium3, pentium4, athlon, opteron, amd64, sparc32, sparc64, ppc64
--without-pcre                禁用pcre库
--with-pcre                    启用pcre库
--with-pcre=DIR                指向pcre库文件目录
--with-pcre-opt=OPTIONS        在编译时为pcre库设置附加参数
--with-pcre-jit                
--with-md5=DIR                指向md5库文件目录
--with-md5-opt=OPTIONS        在编译时为md5库设置附加参数
--with-md5-asm                使用md5汇编源
--with-sha1=DIR                指向sha1库目录(数字签名算法,主要用于数字签名)
--with-sha1-opt=OPTIONS        在编译时为sha1库设置附加参数
--with-sha1-asm                使用sha1汇编源
--with-zlib=DIR                指向zlib库目录
--with-zlib-opt=OPTIONS     在编译时为zlib设置附加参数
--with-zlib-asm=CPU            为指定的CPU使用zlib汇编源进行优化,CPU类型为pentium, pentiumpro

--with-libatomic            为原子内存的更新操作的实现提供一个架构
--with-libatomic=DIR        指向libatomic_ops安装目录

--with-openssl=DIR            指向openssl安装目录
--with-openssl-opt=OPTIONS    在编译时为openssl设置附加参数

--with-debug                启用debug日志

CMakelist.txt:

cmake_minimum_required(VERSION 3.10.2)
project(nginx)


# -------------------------------version---------------------------------------------- #
set(main_version 1)
set(mdl_version 1)
set(sub_version 6)
set(version ${main_version}.${mdl_version}.${sub_version})

MESSAGE("CT: ${CT}")
if(NOT CT)
    set(CT "lp")
    MESSAGE("CT: ${CT}")
endif()

MESSAGE("ODIR: ${ODIR}")
if(NOT ODIR)
    set(ODIR ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_${version}/)
    MESSAGE("ODIR: ${ODIR}")
else()
    set(ODIR ${ODIR}/${PROJECT_NAME})
    MESSAGE("ODIR: ${ODIR}")
endif()


# 设置源码路径 CMakeFiles/nginx.dir/nginx-1.18.0
set(NGINX_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/nginx-1.18.0")
set(FLV_MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/nginx-http-flv-module")


set(CMAKE_SYSROOT /opt/bstos/linux-23/sysroots/aarch64-bst-linux)
# -------------------------------compile flag---------------------------------------------- #
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --sysroot=${CMAKE_SYSROOT} -O0 -std=c++17 -s -lcrypt")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --sysroot=${CMAKE_SYSROOT} -I${OPENSSL_INCLUDE_DIR} -O2 -Wall -Werror -g -lcrypt")

#set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --sysroot=${CMAKE_SYSROOT} -static")
# Specify the cross compiler
#set(CMAKE_C_COMPILER /opt/bstos/linux-23/sysroots/x86_64-bstsdk-linux/usr/bin/aarch64-bst-linux/aarch64-bst-linux-gcc)
#set(CMAKE_C_COMPILER /usr/local/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc)
#set(CMAKE_CXX_COMPILER /opt/bstos/linux-23/sysroots/x86_64-bstsdk-linux/usr/bin/aarch64-bst-linux/aarch64-bst-linux-g++)

# Add extra compiler flags
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --sysroot=${CMAKE_SYSROOT}")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --sysroot=${CMAKE_SYSROOT}")
#set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --sysroot=${CMAKE_SYSROOT}")
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${OPENSSL_INCLUDE_DIR}")

find_program(CONFIGURE_EXECUTABLE configure PATHS "${NGINX_SRC_DIR}")
execute_process(
    COMMAND ${CONFIGURE_EXECUTABLE} --prefix=/usr/local/nginx --with-threads --with-file-aio --with-ld-opt=-static --add-module=../nginx-http-flv-module --with-http_ssl_module --with-http_flv_module --with-pcre=/path/to/pcre --with-zlib=/path/to/zlib --with-openssl=/path/to/openssl --with-http_dav_module --with-http_degradation_module  --with-http_realip_module --with-http_stub_status_module
    WORKING_DIRECTORY ${NGINX_SRC_DIR}
)


# -------------------------------opencv---------------------------------------------- #
find_package(OpenCV REQUIRED)
IF(OpenCV_FOUND)
    MESSAGE("OpenCV_VERSION:${OpenCV_VERSION}")
    MESSAGE("OpenCV_LIBS:${OpenCV_LIBS}")
    MESSAGE("OpenCV_INCLUDE_DIRS:${OpenCV_INCLUDE_DIRS}")
ENDIF()


# -------------------------------include heard files---------------------------------------------- #
# 包含头文件路径
include_directories(
    ${CMAKE_CURRENT_SOURCE_DIR}
    ${CMAKE_CURRENT_SOURCE_DIR}/nginx-http-flv-module
    ${CMAKE_CURRENT_SOURCE_DIR}/nginx-http-flv-module/hls
    ${NGINX_SRC_DIR}/src/core
    ${NGINX_SRC_DIR}/src/event
    ${NGINX_SRC_DIR}/src/event/modules
    ${NGINX_SRC_DIR}/src/http
    ${NGINX_SRC_DIR}/src/http/v2
    ${NGINX_SRC_DIR}/src/http/modules
    ${NGINX_SRC_DIR}/src/http/modules/perl
    ${NGINX_SRC_DIR}/src/mail
    ${NGINX_SRC_DIR}/src/os/unix
    ${NGINX_SRC_DIR}/src/stream
    ${NGINX_SRC_DIR}/objs  
    ${FLV_MODULE_DIR}
    ${FLV_MODULE_DIR}/dash
    ${FLV_MODULE_DIR}/hls
    ${OPENSSL_INCLUDE_DIR}/opt/bstos/linux-23/sysroots/aarch64-bst-linux/usr/include
)


# Nginx core source files
file(GLOB_RECURSE NGINX_SOURCES 
    "${NGINX_SRC_DIR}/src/core/*.c"
    "${NGINX_SRC_DIR}/src/event/*.c"
    # 只使用 epoll 模块,不使用其他事件模块
    "${NGINX_SRC_DIR}/src/event/modules/ngx_epoll_module.c"
    "${NGINX_SRC_DIR}/src/os/unix/*.c"
    "${NGINX_SRC_DIR}/src/http/*.c"
    "${NGINX_SRC_DIR}/src/http/modules/*.c"
    "${NGINX_SRC_DIR}/objs/src/http/modules/ngx_http_config_module.c"
    "${NGINX_SRC_DIR}/objs/ngx_modules.c"
)

# 显式排除不需要的特定平台模块
list(REMOVE_ITEM NGINX_SOURCES 
    "${NGINX_SRC_DIR}/src/event/modules/ngx_eventport_module.c"
    "${NGINX_SRC_DIR}/src/event/modules/ngx_kqueue_module.c"
    "${NGINX_SRC_DIR}/src/event/modules/ngx_devpoll_module.c" #Solaris
    "${NGINX_SRC_DIR}/src/event/modules/ngx_poll_module.c" #启用poll模块支持(功能与select相同,与select特性相同,为一种轮询模式,不推荐在高载环境下使用)
    "${NGINX_SRC_DIR}/src/event/modules/ngx_select_module.c" #启用select模块支持(一种轮询模式,不推荐在高载环境下使用)
    "${NGINX_SRC_DIR}/src/event/modules/ngx_win32_select_module.c"
    "${NGINX_SRC_DIR}/src/event/modules/ngx_win32_iocp_module.c"
    "${NGINX_SRC_DIR}/src/event/modules/ngx_win32_poll_module.c"    
    "${NGINX_SRC_DIR}/src/http/modules/ngx_http_geoip_module.c"     
    "${NGINX_SRC_DIR}/src/http/modules/ngx_http_image_filter_module.c"    
    "${NGINX_SRC_DIR}/src/http/modules/ngx_http_xslt_filter_module.c"
    "${NGINX_SRC_DIR}/src/http/modules/perl/ngx_http_perl_module.c"    
    "${NGINX_SRC_DIR}/src/os/unix/ngx_darwin_init.c"        
    "${NGINX_SRC_DIR}/src/os/unix/ngx_darwin_sendfile_chain.c"
    "${NGINX_SRC_DIR}/src/os/unix/ngx_file_aio_read.c" #FreeBSD file AIO features and quirks
    "${NGINX_SRC_DIR}/src/os/unix/ngx_freebsd_init.c"
    "${NGINX_SRC_DIR}/src/os/unix/ngx_freebsd_sendfile_chain.c"
    "${NGINX_SRC_DIR}/src/os/unix/ngx_solaris_init.c"
    "${NGINX_SRC_DIR}/src/os/unix/ngx_solaris_sendfilev_chain.c"
)
 

# 使用生成的ngx_modules.c而不是Nginx源码中的
#list(REMOVE_ITEM NGINX_SOURCES "${NGINX_SRC_DIR}/objs/ngx_modules.c")
#list(APPEND NGINX_SOURCES "${CMAKE_BINARY_DIR}/ngx_modules.c")

# 定义必要的宏(根据Nginx配置生成)
# Add necessary compile definitions
add_definitions(
    -DNGX_PREFIX="${CMAKE_INSTALL_PREFIX}"
    -DNGX_CONF_PREFIX="${CMAKE_INSTALL_PREFIX}/conf"
    -DNGX_SBIN_PATH="${CMAKE_INSTALL_PREFIX}/sbin/nginx"
    -DNGX_CONF_PATH="${CMAKE_INSTALL_PREFIX}/conf/nginx.conf"
    -DNGX_PID_PATH="${CMAKE_INSTALL_PREFIX}/logs/nginx.pid"
    -DNGX_LOCK_PATH="${CMAKE_INSTALL_PREFIX}/logs/nginx.lock"
    -DNGX_ERROR_LOG_PATH="${CMAKE_INSTALL_PREFIX}/logs/error.log"
    -DNGX_HTTP_LOG_PATH="${CMAKE_INSTALL_PREFIX}/logs/access.log"
    -DNGX_HTTP_CLIENT_TEMP_PATH="${CMAKE_INSTALL_PREFIX}/client_body_temp"
    -DNGX_HTTP_PROXY_TEMP_PATH="${CMAKE_INSTALL_PREFIX}/proxy_temp"
    -DNGX_HTTP_FASTCGI_TEMP_PATH="${CMAKE_INSTALL_PREFIX}/fastcgi_temp"
    -DNGX_HTTP_UWSGI_TEMP_PATH="${CMAKE_INSTALL_PREFIX}/uwsgi_temp"
    -DNGX_HTTP_SCGI_TEMP_PATH="${CMAKE_INSTALL_PREFIX}/scgi_temp"
    -D_GNU_SOURCE
    -D_FILE_OFFSET_BITS=64
    -DNGX_HAVE_UNISTD_H
    -DNGX_OFF_T_LEN=20
    # 添加缺失的定义
    -DNGX_USER="nobody"
    -DNGX_GROUP="nogroup"
    -DNGX_HAVE_INET6=1
    -DNGX_HAVE_PREAD=1
    -DNGX_HAVE_PWRITE=1
    -DNGX_HAVE_SENDFILE=1
    -DNGX_HAVE_SENDFILE64=1
    -DNGX_HAVE_PR_SET_DUMPABLE=1
    -DNGX_HAVE_SCHED_SETAFFINITY=1
    -DNGX_HAVE_GNU_CRYPT_R=1
    -DNGX_HAVE_NONALIGNED=1
    -DNGX_CPU_CACHE_LINE=64
    -DNGX_HTTP_CACHE=1
    -DNGX_HTTP_GZIP=1
    -DNGX_HTTP_SSI=1
    -DNGX_HTTP_V2=1
    -DNGX_CRYPT=1
    -DNGX_COMPAT=1
    -DNGX_HTTP_HEADERS=1
    -DNGX_HAVE_TIMER_EVENT=1
    -DNGX_SIZE_T_LEN=20  # 添加缺失的 NGX_SIZE_T_LEN 定义
    # 添加新缺失的宏定义
    -DNGX_MAX_SIZE_T_VALUE=9223372036854775807UL  # 64位系统下size_t最大值
    -DNGX_MAX_OFF_T_VALUE=9223372036854775807LL   # 64位系统下off_t最大值
    # 添加 epoll 相关的编译定义
    -DNGX_HAVE_EPOLL=1
    -DNGX_HAVE_EPOLL_EVENT=1
    -DNGX_HAVE_CLEAR_EVENT=1
    -DNGX_LINUX=1
    -DNGX_HTTP_FLV_MODULE
)

# 添加FLV模块源码
file(GLOB FLV_MODULE_SOURCES 
    ${FLV_MODULE_DIR}/*.c
    ${FLV_MODULE_DIR}/hls/*.c
    ${FLV_MODULE_DIR}/dash/*.c)
    
list(APPEND NGINX_SOURCES ${FLV_MODULE_SOURCES})

# 查找依赖库(configure时,需提前静态编译)
find_library(PCRE_LIB pcre HINTS /path/to/pcre-arm/lib REQUIRED)
find_library(SSL_LIB ssl HINTS /path/to/openssl-arm/lib REQUIRED)
find_library(CRYPTO_LIB crypto HINTS /path/to/openssl-arm/lib REQUIRED)
find_library(ZLIB_LIB z HINTS /path/to/zlib-arm/lib REQUIRED)


ADD_EXECUTABLE(${PROJECT_NAME}  ${NGINX_SOURCES})

# 链接依赖库
target_link_libraries(${PROJECT_NAME}
    ${PCRE_LIB}
    ${SSL_LIB}
    ${CRYPTO_LIB}
    ${ZLIB_LIB}
    -ldl -lpthread
)


 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/bicheng/74956.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

PyQt6实例_批量下载pdf工具_主线程停止线程池

目录 前置: 代码: 视频: 前置: 1 本系列将以 “PyQt6实例_批量下载pdf工具”开头,放在 【PyQt6实例】 专栏 2 本系列涉及到的PyQt6知识点: 线程池:QThreadPool,QRunnable; 信号与…

Tomcat生产服务器性能优化

试想以下这个情景:你已经开发好了一个程序,这个程序的排版很不错,而且有着最前沿的功能和其他一些让你这程序增添不少色彩的元素。可惜的是,程序的性能不怎么地。你也十分清楚,若现在把这款产品退出市场,肯…

正则表达式-笔记

文章目录 一、正则表达式二、正则表达式的基本语法字符类普通字符非打印字符特殊字符 量词限定符锚点修饰符(标记) 三、在 Python 中使用正则表达式简单搜索提取信息替换文本 参考 从验证用户输入,到从大量文本中提取特定信息,再到…

Qwen-0.5b linux部署

参考链接 https://blog.csdn.net/imwaters/article/details/145489543 https://modelscope.cn/models/modelscope/ollama-linux 1. ollama安装 # 安装ModelScope工具包,用于下载和管理AI模型 pip install modelscope# 下载Ollama的Linux版本安装包 # --model 指定…

【深度学习】GAN生成对抗网络:原理、应用与发展

GAN生成对抗网络:原理、应用与发展 文章目录 GAN生成对抗网络:原理、应用与发展1. 引言2. GAN的基本原理2.1 核心思想2.2 数学表达2.3 训练过程 3. GAN的主要变体3.1 DCGAN (Deep Convolutional GAN)3.2 CGAN (Conditional GAN)3.3 CycleGAN3.4 StyleGAN…

【AI速读】CNN图像处理单元的形式化验证方法

近年来,卷积神经网络(CNN)在图像处理和计算机视觉领域取得了巨大成功,如人脸识别、姿态估计等。然而,基于CNN的图像处理单元设计复杂,验证工作面临巨大挑战。传统的仿真验证方法难以覆盖其庞大的配置空间,且耗时费力。本文将介绍一种创新的形式化验证(Formal Verificat…

【新人系列】Golang 入门(八):defer 详解 - 上

✍ 个人博客:https://blog.csdn.net/Newin2020?typeblog 📝 专栏地址:https://blog.csdn.net/newin2020/category_12898955.html 📣 专栏定位:为 0 基础刚入门 Golang 的小伙伴提供详细的讲解,也欢迎大佬们…

鸿蒙开发:了解Canvas绘制

前言 本文基于Api13 系统的组件无法满足我们的需求,这种情况下就不得不自己自定义组件,除了自定义组合组件,拓展组件,还有一种方式,那就是完全的自绘制组件,这种情况,常见的场景有,比…

【Linux笔记】进程间通信——命名管道

🔥个人主页🔥:孤寂大仙V 🌈收录专栏🌈:Linux 🌹往期回顾🌹:【Linux笔记】进程间通信——匿名管道||进程池 🔖流水不争,争的是滔滔不 一、命名管道…

Spring项目中使用EasyExcel实现Excel 多 Sheet 导入导出功能(完整版)

Excel 多 Sheet 导入导出功能完整实现指南 一、环境依赖 1. Maven 依赖 <!-- EasyExcel --> <dependency><groupId>com.alibaba</groupId><artifactId>easyexcel</artifactId><version>3.3.2</version> </dependency>…

全流程剖析需求开发:打造极致贴合用户的产品

全流程剖析需求开发&#xff1a;打造极致贴合用户的产品 一、需求获取&#xff08;一&#xff09;与用户沟通1.面谈2.问卷调查3.会议讨论 &#xff08;二&#xff09;观察用户工作&#xff08;三&#xff09;收集现有文档 二、需求分析&#xff08;一&#xff09;提炼关键需求&…

SQL语句及其应用(中)(DQL语句之单表查询)

SQL语句的定义: 概述: 全称叫 Structured Query Language, 结构化查询语言, 主要是实现 用户(程序员) 和 数据库软件(例如: MySQL, Oracle)之间交互用的. 分类: DDL: 数据定义语言, 主要是操作 数据库, 数据表, 字段, 进行: 增删改查(CURD) 涉及到的关键字: create, drop, …

5000元组装一台本地运行中、小模型主机,参考配置 (运行DeepSeek、Qwen)

5000元组装一台本地运行中、小模型主机&#xff0c;参考配置 &#xff08;运行DeepSeek、Qwen) 5000元中、小模型主机 DeepSeek、Qwen 各精度模型推荐启动方式 模型名称 参数量 精度 模型大小 推荐运行模式 DeepSeek R1 7b Q4 5 GB LM Studio纯GPU 14b Q4 9 GB LM…

【新手初学】SQL注入getshell

一、引入 木马介绍&#xff1a; 木马其实就是一段程序&#xff0c;这个程序运行到目标主机上时&#xff0c;主要可以对目标进行远程控制、盗取信息等功能&#xff0c;一般不会破坏目标主机&#xff0c;当然&#xff0c;这也看黑客是否想要搞破坏。 木马类型&#xff1a; 按照功…

Containerd+Kubernetes搭建k8s集群

虚拟机环境设置&#xff0c;如果不是虚拟机可以忽略不看 1、安装配置containerd 1.1 添加 Kubernetes 官方仓库 安装cri-tools的时候需要用到 cat > /etc/yum.repos.d/kubernetes.repo << EOF [kubernetes] nameKubernetes baseurlhttps://mirrors.aliyun.com/kub…

应用待机分组管控是啥

1. 应用待机群组是啥&#xff1f; Android 9 引入了一个新功能&#xff0c;叫应用待机群组。简单来说&#xff0c;就是根据你最近使用应用的频率和时间&#xff0c;系统会把应用分成不同的“群组”。每个群组的应用能用的系统资源不一样&#xff0c;比如后台任务、闹钟、网络请…

C/C++后端开发面经

字节跳动 客户端开发 实习 一面(50min) 自我介绍是否愿意转语言,是否只愿意搞后端选一个项目来详细谈谈HTTP和HTTPS有什么区别?谈一下HTTPS加密的具体过程&#xff1a; 非对称加密 对称加密 证书认证的方式 非对称加密是为了保证对称密钥的安全性。 对称…

【第十三届“泰迪杯”数据挖掘挑战赛】【2025泰迪杯】A题解题全流程(持续更新)

【第十三届“泰迪杯”数据挖掘挑战赛】【2025泰迪杯】A题解题全流程-思路&#xff08;持续更新&#xff09; 写在前面&#xff1a; 1、A题、C题将会持续更新&#xff0c;陆续更新发布文章 2、赛题交流咨询Q群&#xff1a;1037590285 3、全家桶依旧包含&#xff1a; 代码、…

如何让 history 记录命令执行时间?Linux/macOS 终端时间戳设置指南

引言:你真的会用 history 吗? 有没有遇到过这样的情况:你想回顾某个重要命令的执行记录,却发现 history 只列出了命令序号和内容,根本没有时间戳?这在运维排查、故障分析、甚至审计时都会带来极大的不便。 想象一下,你在服务器上误删了某个文件,但不知道具体是几点执…

Redis缓存异常场景深度解析:穿透、击穿、雪崩及终极解决方案

一、引言 在高并发系统中&#xff0c;缓存承担着流量洪峰的削峰填谷作用。然而当缓存层出现异常时&#xff0c;可能引发数据库级联崩溃&#xff0c;造成系统瘫痪。本文将深入剖析缓存穿透、缓存击穿、缓存雪崩三大典型问题&#xff0c;并提供企业级解决方案。文章包含7种防御策…