RTMP ssl_preread module nginx 모듈 포함하여 Windows에서 빌드

RTMP ssl_preread module nginx 빌드 준비

RTMP ssl_preread module nginx 빌드를 Windows 환경에서 하기 위한 설명은 아래에 있는데 공식 설명 이외의 추가적인 작업들이 있어 도움이 되었으면 합니다.

http://nginx.org/en/docs/howto_build_on_win32.html


먼저, nginx를 빌드하려면 다음과 같은 요소들이 필요합니다:

Microsoft Visual C 컴파일러
MSYS 또는 MSYS2
Perl (예: ActivePerl 또는 Strawberry Perl)
Mercurial 클라이언트
PCRE, zlib 및 OpenSSL 라이브러리 소스

sed 설치 https://gnuwin32.sourceforge.net/packages/sed.htm

RTMP https://github.com/arut/nginx-rtmp-module

clone https://github.com/arut/nginx-rtmp-module.git

PERL 설치

OpenSSL을 빌드하기 위해 Perl이 필요하므로, 해당 에러를 해결하려면 Perl을 설치하고 경로를 설정해야 합니다.

Perl을 설치합니다. Strawberry Perl을 사용할 수 있습니다.
설치한 Perl의 bin 폴더를 환경 변수 PATH에 추가합니다. 일반적으로 Perl의 bin 폴더는 Perl을 설치한 디렉토리 안에 있습니다.

  1. Perl 다운로드 링크접속 – Perl Download
  2. 위의 Perl 사이트에서 Windows – Strawbarry Perl 설치
  3. 설치 후 CMD 창을 열어 “Perl -v” 명령어를 입력하여 설치확인
  4. 환경 변수 PATH에 Perl의 경로를 추가한 후, 다시 nmake 명령을 실행해보세요. Perl 관련 에러가 해결되어야 합니다.

C:\Strawberry\perl\bin

Sed 설치

sed 설치 https://gnuwin32.sourceforge.net/packages/sed.htm

C:\Program Files (x86)\GnuWin32\bin

MSYS2 설치

https://woogyun.tistory.com/705

Microsoft Visual C 컴파일러 설치

Microsoft Visual C 컴파일러

RTMP, ssl_preread module nginx 빌드

RTMP ssl_preread module nginx 모듈 포함하여 Windows에서 빌드는 아래의 과정으로 진행 하시면 됩니다.

MSYS2 실행하여 아래 명령 실행

pacman -S make gcc perl mercurial
hg clone http://hg.nginx.org/nginx

실행하고 생긴 nginx폴더에 준비한 모듈파일들을 넣고 압축을 풀어줍니다.

C:\msys64\home\사용자\nginx\objs\lib

경로로 폴더를 생성하고

nginx-rtmp-module-master

openssl-1.1.1v.tar

pcre2-10.42.tar

zlib-1.3.tar

파일 등등 원하는 파일을 넣고 압축해제

원하는 모듈을 넣고 아래 명령어로 MSYS2 에서 configure생성

auto/configure \
    --with-cc=cl \
    --with-debug \
    --prefix= \
    --conf-path=conf/nginx.conf \
    --pid-path=logs/nginx.pid \
    --http-log-path=logs/access.log \
    --error-log-path=logs/error.log \
    --sbin-path=nginx.exe \
    --http-client-body-temp-path=temp/client_body_temp \
    --http-proxy-temp-path=temp/proxy_temp \
    --http-fastcgi-temp-path=temp/fastcgi_temp \
    --http-scgi-temp-path=temp/scgi_temp \
    --http-uwsgi-temp-path=temp/uwsgi_temp \
    --with-cc-opt=-DFD_SETSIZE=1024 \
    --with-pcre=objs/lib/pcre2-10.42 \
    --with-zlib=objs/lib/zlib-1.3 \
    --with-openssl=objs/lib/openssl-1.1.1v \
    --with-openssl-opt=no-asm \
    --with-http_ssl_module \
    --add-module=C:/msys64/home/ToToro/nginx/objs/lib/nginx-rtmp-module-master/ \
    --with-stream \
    --with-stream_ssl_preread_module
    --with-stream_ssl_module

23-09-05 –with-stream_ssl_module 추가

이 모듈은 stream 블록에서 SSL을 사용하기 위해 필요합니다.

stream 블록은 TURN 서비스를 위한 것이고, http 블록은 웹 서비스제공

RTMP ssl_preread module nginx

makefile이 잘생성되었습니다.

cmd를 실행하여 경로로 이동하

cd C:\msys64\home\ToToro\nginx

cmd를 실행하여 경로로 nmake를 하기전 본인의 비쥬얼스튜디오 경로 vcvarsall.bat 파일 지정

“C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvarsall.bat” x86_amd64

cmd에서 nmake를 실행합니다.

실행하면 저같이 오류가 납니다 git에서 받은 파일을 변경하지도 않았는데 오류가있는데요

NMAKE : fatal error U1077: ‘cl -c -O2 -W4 -WX -nologo -MT -Zi -Fdobjs/nginx.pdb -DFD_SETSIZE=1024 -DNO_SYS_TYPES_H -Yungx_config.h -Fpobjs/ngx_config.pch -I src/core -I src/event -I src/event/modules -I src/event/quic -I src/os/win32 -I C:/msys64/home/ToToro/nginx/objs/lib/nginx-rtmp-module-master/ -I objs/lib/pcre2-10.42/src/ -I objs/lib/openssl-1.1.1v/openssl/include -I objs/lib/zlib-1.3 -I objs -I src/http -I src/http/modules -I src/stream -Foobjs/addon/nginx-rtmp-module-master/ngx_rtmp_core_module.obj C:/msys64/home/ToToro/nginx/objs/lib/nginx-rtmp-module-master//ngx_rtmp_core_module.c’ : ‘0x2’ 반환 코드입니다.
Stop.
NMAKE : fatal error U1077: ‘”C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.36.32532\bin\HostX86\x64\nmake.exe” -f objs/Makefile’ : ‘0x2’ 반환 코드입니다.
Stop.

별에별 오류가………………

obj안에 makefile을 텍스트로 여시면 두번째 줄에 아래의 내용이 있는데요 아래 부분을

CFLAGS =  -O2  -W4 -WX -nologo -MT -Zi -Fdobjs/nginx.pdb -DFD_SETSIZE=1024 -DNO_SYS_TYPES_H

이렇게 고쳐줍니다.

CFLAGS =  -O2  -W3 -nologo -MT -Zi -Fdobjs/nginx.pdb -DFD_SETSIZE=1024 -DNO_SYS_TYPES_H

그다음 다시 cmd에서 nmake를 실행하면 끝

RTMP ssl_preread module nginx 윈도우 빌드완료

코딩초보가 webrtc하나 해보겠다고 어디까지 가는지 모르겠습니다……… https로 만들기위해 ssl발급….webrtc를 힘들게 만들었더니 외부접속을 위해 stun서버 ……. 와 webrtc를 라우팅하기위해 nginx를 직접 빌드까지…….휴

댓글 남기기

%d 블로거가 이것을 좋아합니다: