Step 1: Update System
sudo apt update && sudo apt upgrade -y
Step 2: Install Dependencies
sudo apt install -y \
git build-essential cmake libmicrohttpd-dev libjansson-dev \
libnice-dev libssl-dev libsrtp2-dev libsofia-sip-ua-dev \
libglib2.0-dev libopus-dev libogg-dev libini-config-dev \
libcollection-dev pkg-config gengetopt libtool automake \
libwebsockets-dev libnanomsg-dev
export PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/share/pkgconfig
Step 3: Clone and Build Janus
git clone https://github.com/meetecho/janus-gateway.git
cd janus-gateway
sh autogen.sh
./configure --prefix=/opt/janus
make
sudo make install
sudo make configs
Step 4: Add Janus to the System Path
echo 'export PATH=$PATH:/opt/janus/bin' >> ~/.bashrc
source ~/.bashrc
Step 5: Open Required Ports
Step 6: Run as a Service
Step 1: Create systemd service file
sudo nano /etc/systemd/system/janus.service
Paste:
[Unit]
Description=Janus WebRTC Gateway
After=network.target
[Service]
ExecStart=/opt/janus/bin/janus
Restart=on-failure
User=www-data
Group=www-data
[Install]
WantedBy=multi-user.target
Save the file by executing this command Ctrl+x , y
sudo systemctl daemon-reexec
sudo systemctl daemon-reload
sudo systemctl enable janus
sudo systemctl start janus
Check status:
sudo systemctl status janus
Step 7: Setup HTTPS/WSS
sudo apt update
sudo apt install certbot
sudo certbot certonly --standalone -d x.protocol.in
sudo mkdir -p /opt/janus/certs
sudo cp /etc/letsencrypt/live/x.protocol.in/fullchain.pem /opt/janus/certs/
sudo cp /etc/letsencrypt/live/x.protocol.in/privkey.pem /opt/janus/certs/
sudo chmod 640 /opt/janus/certs/*
sudo chown www-data:www-data /opt/janus/certs/*
sudo nano /opt/janus/etc/janus/janus.transport.http.jcfg
https = true # Whether to enable HTTPS (default=false)
secure_port = 8089 # Web server HTTPS port, if enabled
cert_pem = "/opt/janus/certs/fullchain.pem"
cert_key = "/opt/janus/certs/privkey.pem"
sudo nano /opt/janus/etc/janus/janus.transport.websockets.cfg
wss = true # Whether to enable secure WebSockets
wss_port = 8889 # WebSockets server secure port, if enabled
cert_pem = "/opt/janus/certs/fullchain.pem"
cert_key = "/opt/janus/certs/privkey.pem"
Restart Janus
sudo systemctl restart janus
sudo ss -tulnp | grep janus
Install Demos
cd ~
git clone https://github.com/meetecho/janus-gateway.git
sudo mkdir -p /opt/janus/share/janus/
sudo cp -r janus-gateway/html /opt/janus/share/janus/demos
To Run demo:
cd /opt/janus/share/janus/demos
nohup python3 https_server1.py > janus_https.log 2>&1 &
Open in Browser
https://<yourdomain>:8081/