Ubuntu에 janus-gateway 설치하기

2 분 소요

참고 블로그

설치 환경

  • 가상 머신 : VMWare Work Station 16 Player
  • Linux OS : ubuntu-20.04.2.0-desktop-amd64
  • 설치 일자 : 2021-08-13

개발툴 설치

sudo -i
apt-get install aptitude vim gcc g++ autopoint git autoconf make cmake python3 python3-pip gettext texinfo

Janus의 의존성(디펜던시) 설치

aptitude install libmicrohttpd-dev libjansson-dev \
	libssl-dev libsrtp2-dev libsofia-sip-ua-dev libglib2.0-dev \
	libopus-dev libogg-dev libcurl4-openssl-dev liblua5.3-dev \
	libconfig-dev pkg-config gengetopt libtool automake

meson & ninja 설치

pip3 install meson
ln -s /usr/local/bin/meson /usr/bin/
cd /home/ec2-user/
wget https://github.com/ninja-build/ninja/releases/download/v1.10.1/ninja-linux.zip
unzip ninja-linux.zip
cp ninja /usr/bin/

libsrtp2 삭제

aptitude remove libsrtp2-dev 

libsrtp2 버전 다운해서 다시 설치

wget https://github.com/cisco/libsrtp/archive/v2.2.0.tar.gz
tar xfv v2.2.0.tar.gz
cd libsrtp-2.2.0
./configure --prefix=/usr --enable-openssl
make shared_library && sudo make install

libnice 설치

cd ~
git clone https://gitlab.freedesktop.org/libnice/libnice
cd libnice
meson --prefix=/usr build && ninja -C build && sudo ninja -C build install

usrsctp 설치

cd ~
git clone https://github.com/sctplab/usrsctp
cd usrsctp
./bootstrap
./configure --prefix=/usr --disable-programs --disable-inet --disable-inet6
make && sudo make install

libwebsockets 설치

cd ~
git clone https://github.com/warmcat/libwebsockets.git
cd libwebsockets
# If you want the stable version of libwebsockets, uncomment the next line
# git checkout v3.2-stable
mkdir build
cd build
# See https://github.com/meetecho/janus-gateway/issues/732 re: LWS_MAX_SMP
# See https://github.com/meetecho/janus-gateway/issues/2476 re: LWS_WITHOUT_EXTENSIONS
cmake -DLWS_MAX_SMP=1 -DLWS_WITHOUT_EXTENSIONS=0 -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_C_FLAGS="-fpic" ..
make && sudo make install

MQTT 설치

cd ~
git clone https://github.com/eclipse/paho.mqtt.c.git
cd paho.mqtt.c
make && sudo prefix=/usr make install

libnanomsg-dev 설치

cd ~
aptitude install libnanomsg-dev

rabbitmq-c 설치

cd ~
git clone https://github.com/alanxz/rabbitmq-c
cd rabbitmq-c
git submodule init
git submodule update
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr ..
make && sudo make install

janus gate way compile

/opt/janus 디렉토리에 패키지 설치

cd ~
git clone https://github.com/meetecho/janus-gateway.git
cd janus-gateway/
sh autogen.sh
sudo ./configure --prefix=/opt/janus
sudo make
sudo make install
sudo make configs   # 기본설정파일 생성.

apache2 웹서버 설치

apt-get install apache2
service apache2 start

ssl 설정

cd ~
apt-get install openssl
mkdir /etc/apache2/ssl
cd /etc/apache2/ssl
openssl genrsa -des3 -out server.key 2048
# 여기서 비번 입력하라는 창이 나온다. 잘 기억할것

openssl req -new -key server.key -out server.csr
# 여기서 나라이름, 뭐 어쩌고저쩌고 많이 뜬다. 대충 입력하고
# A challenge password, An optional company name은 입력하지 않고 엔터만 누른다.

cp server.key server.key.origin
openssl rsa -in server.key.origin -out server.key
# 여기에서 맨 처음에 입력했던 비밀번호를 입력한다. 패스워드를 제거하는 작업

openssl x509 -req -days 3650 -in server.csr -signkey server.key -out server.crt
# 10년짜리 (3650일짜리) ssl 인증서를 만든다.
a2enmod ssl
systemctl restart apache2
cp /etc/apache2/sites-available/default-ssl.conf /etc/apache2/sites-available/hanalive.kro.kr.conf

vim /etc/apache2/sites-available/hanalive.kro.kr.conf
a2ensite hanalive.kro.kr
service apache2 restart

https://hanalive.kro.kr 로 접속해서 apache2 index페이지가 뜨는지 확인하기

설정 파일 셋팅

janus.jcfg 변경

cd /opt/janus/etc/janus
vim janus.jcfg
general: {
  log_to_file = "/opt/janus/log/janus.log"  # Whether to use a log file or not
}
certificates: {
  cert_pem = "/usr/local/antmedia/conf/fullchain.pem"
  cert_key = "/usr/local/antmedia/conf/privkey.pe:m"
  # 비밀번호는 ssl암호
}
vim /opt/janus/etc/janus/janus.transport.http.jcfg
  cert_pem = "/usr/local/antmedia/conf/fullchain.pem"
  cert_key = "/usr/local/antmedia/conf/privkey.pe:m"
  # 비밀번호는 ssl암호
/opt/janus/bin/janus -F /opt/janus/etc/janus -S stun.l.google.com:19302 -b