-
Notifications
You must be signed in to change notification settings - Fork 1k
Set up my own Stream Server
Source Information:
Note: This guide recommends using Ubuntu 24.04 or newer for optimal performance and compatibility.
Before installing Nginx RTMP, ensure your server is up-to-date. This guide is designed for Ubuntu 24.04 but is adaptable for other versions.
Run the following commands to install the required packages and set up Nginx RTMP:
sudo apt-get update -y && sudo apt-get upgrade -y
sudo apt-get install -y build-essential libpcre3 libpcre3-dev zlib1g zlib1g-dev libssl-dev
sudo mkdir ~/build && cd ~/build
sudo git clone https://github.com/arut/nginx-rtmp-module.git
sudo wget http://nginx.org/download/nginx-1.16.1.tar.gz && sudo tar xzf nginx-1.16.1.tar.gz
cd nginx-1.16.1
sudo ./configure --with-http_ssl_module --with-http_stub_status_module --with-http_auth_request_module --add-module=../nginx-rtmp-module
sudo make && sudo make install- Download the RTMP statistics stylesheet:
cd /usr/local/nginx/html
sudo wget https://raw.githubusercontent.com/WWBN/AVideo/master/plugin/Live/install/stat.xsl- Set up the RTMP configuration by replacing the existing Nginx configuration file:
sudo mv /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.old
cd /usr/local/nginx/conf/
sudo wget https://raw.githubusercontent.com/WWBN/AVideo/master/plugin/Live/install/nginx.conf- Open and edit the configuration file to add your domain name:
sudo nano /usr/local/nginx/conf/nginx.confBefore proceeding with SSL setup, ensure that your domain name is correctly set in the nginx.conf file:
- In the
serverblock under thehttpsection, add your domain name as follows:
server {
listen 8080;
server_name yourdomain.com; # Replace with your actual domain name
location /live {
root /HLS; # HLS root path
# Additional location configurations as needed...
}
}Replace yourdomain.com with your actual domain name. This step is crucial as Let's Encrypt will use this domain to validate and issue the SSL certificate.
Ensure that the directories for HLS segments exist:
sudo mkdir /HLS && sudo mkdir /HLS/liveThese directories will store HLS fragments generated by the Nginx RTMP server.
Once your domain is correctly set in the nginx.conf file, you can proceed to obtain an SSL certificate:
- Install Certbot for Nginx:
sudo apt install -y certbot python3-certbot-nginx- Run Certbot to obtain and configure the SSL certificate:
sudo certbot --nginx --nginx-server-root /usr/local/nginx/conf --no-redirectCertbot will read the domain name from the nginx.conf file and issue an SSL certificate for it. Make sure your domain's DNS is correctly configured to point to your server's IP address before running Certbot.
After obtaining the certificate, modify the SSL configuration in nginx.conf to use port 8443:
- Edit the
nginx.conffile:
sudo nano /usr/local/nginx/conf/nginx.conf- Add or modify the SSL block to look like this:
server {
listen 8443 ssl;
ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;
server_name yourdomain.com;
location /live {
root /HLS; # HLS root path
# Additional location configurations as needed...
}
}Ensure yourdomain.com matches the domain name you used with Certbot.
Start Nginx with the following command:
sudo /usr/local/nginx/sbin/nginxNotes:
- If Nginx is already running, you may receive a message indicating it. This is not an error.
- To stop Nginx:
sudo /usr/local/nginx/sbin/nginx -s stop- To restart Nginx:
sudo /usr/local/nginx/sbin/nginx -s stop && sudo /usr/local/nginx/sbin/nginxCheck the RTMP statistics page to ensure the server is running correctly:
http://[your IP or domain]:8080/stat
This page displays the status of your RTMP server and active streams.
The Open Source Video Platform Solution
| Service | Description | Link |
|---|---|---|
| 🏢 | WWBN Solutions - Enterprise consulting and custom development | Visit |
| 🎯 | Professional Support - Direct assistance from core developers | Contact |
| ☁️ | AVideo CDN - High-performance video delivery network | Pricing |
AVideo Platform © 2024 - Self-hosted video streaming platform
Made with ❤️ by WWBN and the open source community