본문 바로가기
Server

라이브 스트리밍 서버 설정 nginx-rtmp

by 오늘도 깨달았다 2022. 6. 13.
반응형

nginx-rtmp 는 설치 완료됐다고 가정

 

 

 

에러 : nginx 유저가 없음 

에러메세지 : nginx: [emerg] getpwnam("nginx") failed in /usr/local/nginx/conf/nginx.conf:1

해결 : sudo useradd -s /bin/bash -m nginx

 

 

 


rtmp 모듈의 기능 중 on publish , on done 으로 사용자 인증 & 썸네일 생성 트리거 활용을 위한 nodejs 서버 환경설정

node js 설치 경로       /usr/local/nginx

//순서대로 명령어를 치시오
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash

source ~/.bashrc

nvm install 17.9.0

apt install npm 

//익스프레스 프레임워크 설치 
npm install --save express

// 다 기본설정으로 하기 때문에 계속 엔터 후 yes 
npm init


//필요 모듈들 설치 경로 ==> /usr/local/nginx
npm install require

npm install mysql

npm install http

npm install request

//썸네일 생성 library는 global하게
npm install -g hls-live-thumbnails

//nodejs 데몬 관리 툴인 pm2 global하게 설치
npm install -g pm2

 

pm2로 데몬을 관리하기 위해 환경설정 파일 생성 --> /usr/local/nginx 경로

파일 이름 : ecosystem.config.js

module.exports = {
    apps: [{
        name : 'live',
        script: 'index.js',
        instances: 1,
        exec_mode: `cluster`
    },
    {
        name : 'thumbnail',
        script: 'hls-live-thumbnails --ignorePlaylist404 --playlistRetryCount -1  --port 8001 --interval 200 --width 300 --neverDelete',
        instances : 1,
        exec_mode: `fork`
    }]
}

파일을 만들었으면 pm2로 데몬 실행 

pm2 start ecosystem.config.js

//pm2 list 확인
pm2 list

 

반응형

댓글