RTMP stands for Real Time Messaging Protocol. It simply accepts data from the input and forwards it to output, that is simple data transfer. Mostly, RTMP servers are used for streaming. We can stream into different platforms such as Youtube, Twitch, Mixer, etc with the help of OBS studio. OBS studio is an Open Broadcaster Studio which is a free and open source streaming which maintained by OBS project. This article will cover the basic set up of RTMP on a Linux server.

Installing Nginx with RTMP module

SSH into the server and install the necessary modules to set up Nginx using the following command:

$ sudo apt-get install build-essential libpcre3 libpcre3-dev libssl-dev

Get Nginx from source code and we need to get the latest stable version of Nginx:

$ wget http://nginx.org/download/nginx-1.15.7.tar.gz

Next, get the RTMP module from source code:

$ wget https://github.com/sergey-dryabzhinsky/nginx-rtmp-module/archive/dev.zip

Extract Nginx using the following command:

$ tar -zxvf nginx-1.15.7.tar.gz

Unzip the RTMP module:

$ unzip dev.zip

Now change into Nginx Directory:

$ cd nginx-1.15.7

Configure the Nginx using the following command:

$ ./configure --with-http_ssl_module --add-module=../nginx-rtmp-module-dev

Now, we need to install Nginx and RTMP module using the following command:

$make

$make install

After the successful installation, we need to start the Nginx. By default it will reside in /usr/local/nginx, we need to start it:

$ /usr/local/nginx/sbin/nginx

To make sure Nginx is running just type your server IP address in URL and we should get “Welcome to nginx!” page.

Next, open configuration file and add RTMP code at the end of it. Configuration file is located by default at /usr/local/nginx/conf/nginx.conf

Code:

rtmp {
server {
listen 1935;
chunk_size 4096;
application live {
live on;
record off;
}
}
}

Now restart the Nginx with:

$ sudo /usr/local/nginx/sbin/nginx -s stop
$ sudo /usr/local/nginx/sbin/nginx

In order to test this, we need to install OBS studio in our machine and create a custom configuration on OBS broadcast settings.

Streaming Service: Custom
Server: rtmp://<our server ip>/live
Play Path/Stream Key: temp

The stream key is a temporary key which is just made up for this test. We can get the Server and Stream Key from the platform where we want to stream. It varies according to the different platforms. After the configuration in the OBS studio, just hit the Start Streaming button.
So to watch this test stream we need to download VLC player and install it on our local machine. Then open Network Stream on VLC and enter in rtmp://<your server ip>/live/temp as the URL. Now we should be able to watch the stream in VLC.

[tagline_box backgroundcolor=”description=” shadow=”no” shadowopacity=”0.7″ border=”1px” bordercolor=”” highlightposition=”top” content_alignment=”left” link=”” linktarget=”_self” modal=”” button_size=”” button_shape=”” button_type=”” buttoncolor=”” button=”” title=”” description=”If you have any queries on How To Set Up RTMP Server with NGINX feel free to leave us a message and our representative will get back to you.

” margin_top=”50px” margin_bottom=”” animation_type=”slide” animation_direction=”left” animation_speed=”0.3″ class=”” id=””]

    [/tagline_box]