• About Us
  • Disclaimers
  • Privacy Policy
  • Sitemap
Linux Tutorials for Beginners
Advertisement
  • Ubuntu
    Install and Secure phpMyAdmin on Ubuntu 22.04

    How To Install and Secure phpMyAdmin on Ubuntu 22.04

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Ubuntu 22.04

    Install Uptime Kuma on Ubuntu 22.04

    How To Install Uptime Kuma on Ubuntu 22.04

    Install Ubuntu Server 22.04

    How To Install Ubuntu Server 22.04 LTS with Screenshots

    Set Up Firewall on Ubuntu 22.04

    How To Set Up a Firewall with UFW on Ubuntu 22.04

    Install Nginx on Ubuntu

    How To Install Nginx on Ubuntu 22.04: A Comprehensive Guide

    Install MySQL 8.0 on Ubuntu 22.04

    How To Install MySQL 8.0 on Ubuntu Server 22.04

    install-php74-ubuntu2204

    How To Install PHP 7.4 on Ubuntu 22.04

    Install Snipe-IT on Ubuntu 22.04

    How To Install Snipe-IT Asset Management on Ubuntu 22.04

  • Debian
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Debian 11

    Install Debian 11 Server

    How To Install Debian 11 (Bullseye) Server with Pictures

    Install and Setup Node.js on Debian 11

    How To Install and Setup Node.js on Debian 11

    Install PHP 8.2 on Debian 11

    How To Install PHP 8.2 on Debian 11

    Install Nginx on Debian 11

    How To Install Nginx on Debian 11: A Comprehensive Guide

    Set Up Firewall with UFW on Debian

    How To Set Up a Firewall with UFW on Debian 11

    install php74 on debian 11

    How To Install PHP 7.4 on Debian 11

    Install MariaDB 10.9 on Debian 11

    How To Install MariaDB 10.9 on Debian 11 Server

    Initial Setup Debian Server

    Initial Setup Debian 11 Server: Secure and Efficient

  • Rocky Linux
    Install phpMyAdmin on Rocky Linux 9

    How To Install phpMyAdmin on Rocky Linux 9

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Rocky Linux 9

    Install Rocky Linux 9.2 Server

    How To Install Rocky Linux 9.2 Server with Screenshots

    setup Firewall Using Firewalld Rocky Linux 9

    How To Set Up a Firewall Using FirewallD on Rocky Linux 9

    Install Nginx on Rocky Linux 9

    How To Install Nginx on Rocky Linux 9: A Comprehensive Guide

    Install Apache on Rocky Linux

    How To Install and Configure Apache on Rocky Linux 9

    Install MongoDB on Rocky Linux 9

    How To Install MongoDB 6.0 on Rocky Linux 9

    Install Docker on Rocky Linux

    How To Install Docker CE on Rocky Linux 9

  • CentOS
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on CentOS 7

    Install PHP8.2 on CentOS 7

    How To Install PHP 8.2 on CentOS 7 / RHEL 7

    Install Apache on CentOS 7

    How To Install Apache Web Server on CentOS 7

    Set Up FirewallD on CentOS 7

    How To Set Up a Firewall Using FirewallD on CentOS 7

    Initial Setup CentOS 7 Server

    Initial Setup CentOS 7 Server: Secure and Efficient

    Install Nginx on CentOS 7

    How To Install Nginx on CentOS 7: A Comprehensive Guide

    Build NGINX from Source on Centos 7

    How To Build NGINX from Source (Compile) on Centos7

    Install Docker Swarm on CentOS 7

    Install and Configure Docker Swarm Mode on Centos 7

    Install Docker Compose on Centos 7

    How To Install and Use Docker Compose on Centos 7

  • Linux
    Manage Groups on Linux

    A Simple Guide: How To Manage Groups on Linux

    Logrotate In Linux

    How To Manage Log Files Using Logrotate In Linux

    Check File Size in Linux

    The Easy Ways to Check File Size in Linux

    Linux server security system administrators

    Best Practices Linux Server Security for System Administrator

    Backup Files From Remote Linux VPS Using Rsync Script

    How To Backup Files From Remote Linux VPS Using Rsync Script

    SSH Key-based Authentication

    How To Configure SSH Key-based Authentication In Linux

    Linux File Permissions

    Understanding Linux File Permissions for Beginners

    Create Multiboot USB with Ventoy

    How To Create Multiboot USB with Ventoy in Linux

    Find Hard Disk Drive Information in Linux

    How To Find Hard Disk Drive Information in Linux

No Result
View All Result
Linux Tutorials for Beginners
  • Ubuntu
    Install and Secure phpMyAdmin on Ubuntu 22.04

    How To Install and Secure phpMyAdmin on Ubuntu 22.04

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Ubuntu 22.04

    Install Uptime Kuma on Ubuntu 22.04

    How To Install Uptime Kuma on Ubuntu 22.04

    Install Ubuntu Server 22.04

    How To Install Ubuntu Server 22.04 LTS with Screenshots

    Set Up Firewall on Ubuntu 22.04

    How To Set Up a Firewall with UFW on Ubuntu 22.04

    Install Nginx on Ubuntu

    How To Install Nginx on Ubuntu 22.04: A Comprehensive Guide

    Install MySQL 8.0 on Ubuntu 22.04

    How To Install MySQL 8.0 on Ubuntu Server 22.04

    install-php74-ubuntu2204

    How To Install PHP 7.4 on Ubuntu 22.04

    Install Snipe-IT on Ubuntu 22.04

    How To Install Snipe-IT Asset Management on Ubuntu 22.04

  • Debian
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Debian 11

    Install Debian 11 Server

    How To Install Debian 11 (Bullseye) Server with Pictures

    Install and Setup Node.js on Debian 11

    How To Install and Setup Node.js on Debian 11

    Install PHP 8.2 on Debian 11

    How To Install PHP 8.2 on Debian 11

    Install Nginx on Debian 11

    How To Install Nginx on Debian 11: A Comprehensive Guide

    Set Up Firewall with UFW on Debian

    How To Set Up a Firewall with UFW on Debian 11

    install php74 on debian 11

    How To Install PHP 7.4 on Debian 11

    Install MariaDB 10.9 on Debian 11

    How To Install MariaDB 10.9 on Debian 11 Server

    Initial Setup Debian Server

    Initial Setup Debian 11 Server: Secure and Efficient

  • Rocky Linux
    Install phpMyAdmin on Rocky Linux 9

    How To Install phpMyAdmin on Rocky Linux 9

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Rocky Linux 9

    Install Rocky Linux 9.2 Server

    How To Install Rocky Linux 9.2 Server with Screenshots

    setup Firewall Using Firewalld Rocky Linux 9

    How To Set Up a Firewall Using FirewallD on Rocky Linux 9

    Install Nginx on Rocky Linux 9

    How To Install Nginx on Rocky Linux 9: A Comprehensive Guide

    Install Apache on Rocky Linux

    How To Install and Configure Apache on Rocky Linux 9

    Install MongoDB on Rocky Linux 9

    How To Install MongoDB 6.0 on Rocky Linux 9

    Install Docker on Rocky Linux

    How To Install Docker CE on Rocky Linux 9

  • CentOS
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on CentOS 7

    Install PHP8.2 on CentOS 7

    How To Install PHP 8.2 on CentOS 7 / RHEL 7

    Install Apache on CentOS 7

    How To Install Apache Web Server on CentOS 7

    Set Up FirewallD on CentOS 7

    How To Set Up a Firewall Using FirewallD on CentOS 7

    Initial Setup CentOS 7 Server

    Initial Setup CentOS 7 Server: Secure and Efficient

    Install Nginx on CentOS 7

    How To Install Nginx on CentOS 7: A Comprehensive Guide

    Build NGINX from Source on Centos 7

    How To Build NGINX from Source (Compile) on Centos7

    Install Docker Swarm on CentOS 7

    Install and Configure Docker Swarm Mode on Centos 7

    Install Docker Compose on Centos 7

    How To Install and Use Docker Compose on Centos 7

  • Linux
    Manage Groups on Linux

    A Simple Guide: How To Manage Groups on Linux

    Logrotate In Linux

    How To Manage Log Files Using Logrotate In Linux

    Check File Size in Linux

    The Easy Ways to Check File Size in Linux

    Linux server security system administrators

    Best Practices Linux Server Security for System Administrator

    Backup Files From Remote Linux VPS Using Rsync Script

    How To Backup Files From Remote Linux VPS Using Rsync Script

    SSH Key-based Authentication

    How To Configure SSH Key-based Authentication In Linux

    Linux File Permissions

    Understanding Linux File Permissions for Beginners

    Create Multiboot USB with Ventoy

    How To Create Multiboot USB with Ventoy in Linux

    Find Hard Disk Drive Information in Linux

    How To Find Hard Disk Drive Information in Linux

No Result
View All Result
Linux Tutorials for Beginners
No Result
View All Result

Home » CentOS » How To Install RTMP Server with Nginx on CentOS 7

How To Install RTMP Server with Nginx on CentOS 7

sammbysamm
October 16, 2023
Install RTMP with Nginx on CentOS

How To Install RTMP Server with Nginx on CentOS 7

Share on FacebookShare on LinkedinShare on Whatsapp

Introduction

The evolution of live streaming has revolutionized how we consume and share content. Behind the scenes of seamless live streaming lies the RTMP (Real-Time Messaging Protocol) server, a key component that enables real-time transmission of audio and video data over the internet. In this comprehensive guide, we will walk you through the step-by-step process of Install RTMP with Nginx on CentOS 7. By the end of this tutorial, you’ll have a powerful tool to facilitate high-quality live streaming on your CentOS 7 server.

Table of Contents

  • Introduction
  • Understanding RTMP and Nginx
  • Prerequisites
    • Step 1: Update and Upgrade
    • Step 2: Install Dependencies
    • Step 3: Install OpenSSL version 1.1.1h
    • Step 4: Download the Nginx and Nginx-RTMP sources
    • Step 5: Configure Nginx RTMP Module
    • Step 6: Setup First RTMP Live Stream
    • Step 7: Testing RTMP Server
      • Video On Demand Stream
  • Conclusion

Understanding RTMP and Nginx

RTMP is a protocol developed by Adobe that enables real-time communication for audio and video streaming. Nginx, a popular web server, also offers the capability to function as an RTMP server. By harnessing the power of Nginx, you can set up an RTMP server to broadcast live video and audio content to viewers around the world.

OTHER POSTS

How To Secure SSH with Fail2Ban on CentOS 7

How To Install PHP 8.2 on CentOS 7 / RHEL 7

How To Install Apache Web Server on CentOS 7

Nginx RTMP module has a lot of features some of them are listed below :

  • H264/AAC support
  • Online transcoding with FFmpeg
  • Running external programs on certain events (exec)
  • HTTP control module for recording audio/video and dropping clients
  • Advanced buffering techniques to keep memory allocations at a minimum level for faster streaming
  • Stream relay support for distributed streaming: push & pull models

Prerequisites

  • You must have instance least 2GB RAM and 2 Core processor.
  • Operating System : CentOS Linux release 7.9.2009 (Core) | IP Private 172.32.1.230 with root or sudo access, to set this up, follow our guide Initial Setup CentOS 7 Server: Secure and Efficient You can deploy this on a physical machine or a virtual environment like VMware or VirtualBox.
  • A domain name

Step 1: Update and Upgrade

It is recommended that you should install any new packages on a freshly updated server.

First of all, upgrade all the available packages and update the system using the following command.

[samm@server-rtmp ~]$ sudo yum -y update

Step 2: Install Dependencies

We will install Nginx with RTMP module, but before that, you will need to install other dependencies required such as development tools, EPEL repository, and other packages.

Execute the following command to install development tools.

[samm@server-rtmp ~]$ sudo yum -y groupinstall 'Development Tools'
[samm@server-rtmp ~]$ sudo yum -y install epel-release
[samm@server-rtmp ~]$ sudo yum install -y wget git unzip perl perl-devel perl-ExtUtils-Embed libxslt libxslt-devel libxml2 libxml2-devel gd gd-devel pcre-devel GeoIP GeoIP-devel

Step 3: Install OpenSSL version 1.1.1h

Make a working directory and switch to it.

[samm@server-rtmp ~]$ cd /opt
[samm@server-rtmp opt]$ sudo mkdir source
[samm@server-rtmp opt]$ cd source/

sudo wget https://www.openssl.org/source/openssl-1.1.1h.tar.gz && sudo tar xzvf openssl-1.1.1h.tar.gz

[samm@server-rtmp source]$ sudo yum install perl-core zlib-devel -y

[samm@server-rtmp source]$ cd openssl-1.1.1h/

[samm@server-rtmp openssl-1.1.1h]$ sudo ./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl shared zlib

Operating system: x86_64-whatever-linux2
Configuring OpenSSL version 1.1.1h (0x1010108fL) for linux-x86_64
Using os-specific seed configuration
Creating configdata.pm
Creating Makefile

**********************************************************************
*** 
*** OpenSSL has been successfully configured
*** 
*** If you encounter a problem while building, please open an 
*** issue on GitHub <https://github.com/openssl/openssl/issues> 
*** and include the output from the following command: 
*** 
*** perl configdata.pm --dump 
*** 
*** (If you are new to OpenSSL, you might want to consult the 
*** 'Troubleshooting' section in the INSTALL file first) 
*** 
**********************************************************************
[samm@server-rtmp openssl-1.1.1h]$ sudo make
[samm@server-rtmp openssl-1.1.1h]$ sudo make test
[samm@server-rtmp openssl-1.1.1h]$ sudo make install
[samm@server-rtmp openssl-1.1.1h]$ cd /etc/ld.so.conf.d/
[samm@server-rtmp ld.so.conf.d]$ sudo vi openssl-1.1.1h.conf
#add this line
/usr/local/ssl/lib
[samm@server-rtmp ld.so.conf.d]$ sudo ldconfig -v

[samm@server-rtmp ld.so.conf.d]$ sudo mv /bin/openssl /bin/openssl.backup
[samm@server-rtmp ld.so.conf.d]$ sudo vi /etc/profile.d/openssl.sh
#add this line (Set OPENSSL_PATH)
OPENSSL_PATH="/usr/local/ssl/bin"
export OPENSSL_PATH
PATH=$PATH:$OPENSSL_PATH
export PATH

[samm@server-rtmp ld.so.conf.d]$ sudo chmod +x /etc/profile.d/openssl.sh
[samm@server-rtmp ld.so.conf.d]$ source /etc/profile.d/openssl.sh
[samm@server-rtmp ld.so.conf.d]$ echo $PATH
/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/samm/.local/bin:/home/samm/bin:/usr/local/ssl/bin

[samm@server-rtmp ld.so.conf.d]$ which openssl
/usr/local/ssl/bin/openssl
[samm@server-rtmp ~]$ openssl version -a
OpenSSL 1.1.1h 22 Sep 2020
built on: Wed Sep 8 11:04:01 2021 UTC
platform: linux-x86_64
options: bn(64,64) rc4(8x,char) des(int) idea(int) blowfish(ptr) 
compiler: gcc -fPIC -pthread -m64 -Wa,--noexecstack -Wall -O3 -DOPENSSL_USE_NODELETE -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DRC4_ASM -DMD5_ASM -DAESNI_ASM -DVPAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DX25519_ASM -DPOLY1305_ASM -DZLIB -DNDEBUG
OPENSSLDIR: "/usr/local/ssl"
ENGINESDIR: "/usr/local/ssl/lib/engines-1.1"
Seeding source: os-specific

Step 4: Download the Nginx and Nginx-RTMP sources

In this step, we will download nginx source code with the additional dependencies including pcre, zlib, and the Nginx RTMP Module source code.

[samm@server-rtmp source]$ sudo wget http://nginx.org/download/nginx-1.18.0.tar.gz && sudo tar zxvf nginx-1.18.0.tar.gz
[samm@server-rtmp source]$ sudo wget https://ftp.pcre.org/pub/pcre/pcre-8.44.tar.gz && sudo tar xzvf pcre-8.44.tar.gz
[samm@server-rtmp source]$ sudo wget https://www.zlib.net/zlib-1.2.11.tar.gz && sudo tar xzvf zlib-1.2.11.tar.gz
[samm@server-rtmp source]$ sudo git clone https://github.com/sergey-dryabzhinsky/nginx-rtmp-module.git

[samm@server-rtmp source]$ cd nginx-1.18.0

[samm@server-rtmp nginx-1.18.0]$ sudo ./configure --prefix=/etc/nginx \
--sbin-path=/usr/sbin/nginx \
--modules-path=/usr/lib64/nginx/modules \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--user=nginx \
--group=nginx \
--build=CentOS \
--builddir=nginx-1.18.0 \
--with-select_module \
--with-poll_module \
--with-threads \
--with-file-aio \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_xslt_module=dynamic \
--with-http_image_filter_module=dynamic \
--with-http_geoip_module=dynamic \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_auth_request_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_degradation_module \
--with-http_slice_module \
--with-http_stub_status_module \
--with-http_perl_module=dynamic \
--with-perl_modules_path=/usr/share/perl/5.26.1 \
--with-perl=/usr/bin/perl \
--http-log-path=/var/log/nginx/access.log \
--http-client-body-temp-path=/var/cache/nginx/client_temp \
--http-proxy-temp-path=/var/cache/nginx/proxy_temp \
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \
--http-scgi-temp-path=/var/cache/nginx/scgi_temp \
--with-mail=dynamic \
--with-mail_ssl_module \
--with-stream=dynamic \
--with-stream_ssl_module \
--with-stream_realip_module \
--with-stream_geoip_module=dynamic \
--with-stream_ssl_preread_module \
--with-compat \
--with-pcre=../pcre-8.44 \
--with-pcre-jit \
--with-zlib=../zlib-1.2.11 \
--with-openssl=../openssl-1.1.1h \
--with-openssl-opt=no-nextprotoneg \
--add-module=../nginx-rtmp-module \
--with-debug
[samm@server-rtmp nginx-1.18.0]$ sudo make
[samm@server-rtmp nginx-1.18.0]$ sudo make install

Once, the installation is complete create nginx symlink module to the ‘/etc/nginx’ configuration directory.

[samm@server-rtmp ~]$ sudo ln -s /usr/lib64/nginx/modules /etc/nginx/modules

Next, you will need to create a new ‘nginx’ system user and group. Run the following command to do so.

[samm@server-rtmp ~]$ sudo useradd --system --home /var/cache/nginx --shell /sbin/nologin --comment "nginx user" --user-group nginx

[samm@server-rtmp ~]$ sudo tail -n 1 /etc/passwd /etc/group /etc/shadow

==> /etc/passwd <==
nginx:x:998:996:nginx user:/var/cache/nginx:/sbin/nologin

==> /etc/group <==
nginx:x:996:

==> /etc/shadow <==
nginx:!!:18878::::::
[samm@server-rtmp ~]$ sudo mkdir /var/cache/nginx

[samm@server-rtmp ~]$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

[samm@server-rtmp ~]$ sudo vi /usr/lib/systemd/system/nginx.service

[Unit]
Description= VIVANetworks >> Nginx RTMP High Performance Webserver
Documentation=https://nginx.org/en/docs/
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target

[Service]
UMask=0002
Type=forking
PIDFile=/var/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t -c /etc/nginx/nginx.conf
ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID

[Install]
WantedBy=multi-user.target

[samm@server-rtmp ~]$ sudo systemctl start nginx && sudo systemctl enable nginx
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.


[samm@server-rtmp ~]$ sudo systemctl status nginx.service

● nginx.service - VIVANetworks >> Nginx RTMP High Performance Webserver
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
Active: active (running) since Rab 2021-09-08 18:53:31 WIB; 21s ago
Docs: https://nginx.org/en/docs/
Main PID: 24137 (nginx)
CGroup: /system.slice/nginx.service
├─24137 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
└─24138 nginx: worker process

Sep 08 18:53:31 server-rtmp systemd[1]: Starting VIVANetworks >> Nginx RTMP High Performance Webserver...
Sep 08 18:53:31 server-rtmp nginx[24133]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Sep 08 18:53:31 server-rtmp nginx[24133]: nginx: configuration file /etc/nginx/nginx.conf test is successful
Sep 08 18:53:31 server-rtmp systemd[1]: Started VIVANetworks >> Nginx RTMP High Performance Webserver.

Step 5: Configure Nginx RTMP Module

Your Nginx server is active and running as a service on your CentOS 7 system. Now, you will have to create a new nginx configuration for RTMP module and to do so, change your current directory to the nginx configuration directory back up the original configuration file. Execute the following commands and they’ll do the job for you.

[samm@server-rtmp ~]$ cd /etc/nginx/
[samm@server-rtmp nginx]$ sudo mv nginx.conf nginx.conf.default

Create a new nginx configuration file using any text editor using the following command.

[samm@server-rtmp nginx]$ sudo vi nginx.conf


user nginx;
worker_processes auto;
events {
		worker_connections 1024;
		}

# RTMP configuration
	rtmp {
		server {
		listen 1935; # Listen on standard RTMP port
		chunk_size 4096;

	# Define the Application
		application show {
		live 			on;
		# Turn on HLS
		hls 			on;
		hls_path 		/mnt/hls/;
		hls_fragment 		3;
		hls_playlist_length 	60;
		# disable consuming the stream from nginx as rtmp
		deny play all;
		}

		}
	}

		http {
		sendfile off;
		tcp_nopush on;
		aio on;
		directio 512;
		default_type application/octet-stream;

		server {
		server_name rtmp.thevivanetworks.com;
		listen 80;

		location / {
		# Disable cache
		add_header 'Cache-Control' 'no-cache';

		# CORS setup
		add_header 'Access-Control-Allow-Origin' '*' always;
		add_header 'Access-Control-Expose-Headers' 'Content-Length';

		# allow CORS preflight requests
		if ($request_method = 'OPTIONS') {
		add_header 'Access-Control-Allow-Origin' '*';
		add_header 'Access-Control-Max-Age' 1728000;
		add_header 'Content-Type' 'text/plain charset=UTF-8';
		add_header 'Content-Length' 0;
		return 204;
		}

		types {
			application/dash+xml mpd;
			application/vnd.apple.mpegurl m3u8;
			video/mp2t ts;
		}

		root /mnt/;
		}
	}
}
[samm@server-rtmp nginx]$ sudo mkdir -p /mnt/hls
[samm@server-rtmp nginx]$ sudo chown -R nginx:nginx /mnt/hls

[samm@server-rtmp nginx]$ sudo systemctl restart nginx

Step 6: Setup First RTMP Live Stream

All the required dependencies are installed and configured correctly now. Now, let’s create new RTMP stream video on demand using the mp4 videos on the server. You will need to edit the nginx configuration file to do so.

[samm@server-rtmp ~]$ sudo vi /etc/nginx/nginx.conf

Add the following content into the ‘rtmp { … }’ bracket in the file.

# RTMP video on demand for mp4 files
application vod {
play /mnt/mp4s;
}

# RTMP stream using OBS
application stream {
live on;
}
[samm@server-rtmp ~]$ sudo mkdir -p /mnt/mp4s
[samm@server-rtmp ~]$ sudo chown -R nginx:nginx /mnt/mp4s

[samm@server-rtmp ~]$ sudo systemctl restart nginx

Allow Port rtmp (1935) in Firewalld

[samm@server-rtmp ~]$ sudo firewall-cmd --zone=public --permanent --add-port=1935/tcp
success

[samm@server-rtmp ~]$ sudo systemctl restart firewalld

Step 7: Testing RTMP Server

You can test this installation and configuration by using RTMP live stream from the VLC media player. But first copy file a sample video (mp4) to /mnt/mp4s (in this tutorial using surrender.mp4)

Video On Demand Stream

  • Open the VLC media player app on your computer.
  • Click on the ‘File’ menu from the media library and select the Open Network option.
  • Now enter the RTMP URL for our vod stream like this:
    rtmp://172.32.1.230:1935/vod/surrender.mp4 (Only Local)
    Replace YourServerIP with the actual IP address of your server.
  • Finally, click on the Open button. You will get the Video Stream on your screen.

For public access rtmp you can try this link : rtmp://rtmp.sammlinux.com/vod/surrender.mp4

Install RTMP on CentOS
Add link rtmp to video player (VLC)

And Play..

Install RTMP on CentOS
Play RTMP Stream on VLC

Conclusion

Congratulations! You have successfully set up an RTMP server using Nginx on CentOS 7. This powerful configuration allows you to host live streaming events, webinars, and online broadcasts with ease. By combining the capabilities of Nginx and the RTMP protocol, you’ve created a robust platform for real-time audio and video transmission over the internet.

Remember that live streaming demands a stable internet connection and proper configuration to ensure seamless broadcasts. As you continue to explore the world of live streaming, you can further customize your RTMP server to meet specific requirements and integrate it with other services. With your new RTMP server up and running, you’re ready to captivate audiences with captivating live content. Happy streaming!

Also Read Our Other Guides :

  • How To Install Apache Solr 9.1 on Debian 11
  • How To Install Redis on Debian 11 Server
  • How To Install Varnish Cache for Nginx on Rocky Linux 9
  • How To Install Docker CE on Centos 7

Finally, now you have learned how to Install RTMP with Nginx on CentOS 7.

Tags: ApplicationCentOSNginxRTMPStreamingVODWebserver

If you got help by our tutorials, please buy me a coffee..!

Buy Me a Coffee

Thank you so much for your support!!

Previous Post

How To Use Rsync to Sync Local and Remote Directories in Linux

Next Post

How To Install Docker CE on Centos 7

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

RECENT POST

Install and Secure phpMyAdmin on Ubuntu 22.04

How To Install and Secure phpMyAdmin on Ubuntu 22.04

by samm
July 22, 2024
0

Are you ready to take control of your MySQL databases on Ubuntu 22.04? In this step-by-step guide, we'll walk you...

Manage Groups on Linux

A Simple Guide: How To Manage Groups on Linux

by samm
November 12, 2023
0

Are you a Linux enthusiast looking to enhance your system administration skills? One fundamental aspect you should master is how...

Install phpMyAdmin on Rocky Linux 9

How To Install phpMyAdmin on Rocky Linux 9

by samm
November 11, 2023
0

If you're navigating the world of Rocky Linux 9 and looking to streamline your MariaDB or MySQL database management, installing...

Logrotate In Linux

How To Manage Log Files Using Logrotate In Linux

by samm
November 10, 2023
0

Log files are an essential part of any Linux system. They provide valuable insights into the system's activities, helping administrators...

Load More

RECOMMENDED.

Install Redis on Debian

How To Install Redis on Debian 11 Server

October 16, 2023
Secure SSH with Fail2Ban

How To Secure SSH with Fail2Ban on Rocky Linux 9

October 29, 2023
sammlinux sammlinux sammlinux

Related Posts

Secure SSH with Fail2Ban
CentOS

How To Secure SSH with Fail2Ban on CentOS 7

October 29, 2023
Install PHP8.2 on CentOS 7
CentOS

How To Install PHP 8.2 on CentOS 7 / RHEL 7

October 17, 2023
Install Apache on CentOS 7
CentOS

How To Install Apache Web Server on CentOS 7

October 16, 2023
Set Up FirewallD on CentOS 7
CentOS

How To Set Up a Firewall Using FirewallD on CentOS 7

October 17, 2023
Load More
Next Post
Install Docker on Centos 7

How To Install Docker CE on Centos 7

  • About Us
  • Disclaimers
  • Privacy Policy
  • Sitemap

© 2023 sammlinux - Learn Today for Lead Tomorrow.

No Result
View All Result
  • Ubuntu
  • Debian
  • Rocky Linux
  • CentOS
  • Linux

© 2023 sammlinux - Learn Today for Lead Tomorrow.