Professional Documents
Culture Documents
How To Install Nginx With RTMP Module On CentOS 7
How To Install Nginx With RTMP Module On CentOS 7
Log in or Sign up
Tutorial search
Nginx RTMP is a nginx-based media streamer with RTMP, HLS, and MPEG-DASH live
streaming. Nginx RTMP module has lot of features, including H264/AAC support, HTTP
callback support, HTTP control module for recording the audio/video etc.
x
In this tutorial, I will show you how to install and configure the Nginx web server with the
RTMP module. We will be using the latest CentOS 7 server, and this guide will include the
configuration of nginx and rtmp module and creating RTMP live stream and video on
demand.
https://www.howtoforge.com/tutorial/how-to-install-nginx-with-rtmp-module-on-centos/ 1/20
14/3/2021 How to Install Nginx with RTMP Module on CentOS 7
x
Prerequisites
CentOS 7 Server
Root privileges
In this tutorial, we will build the Nginx web server from source. We need to install all
packages dependencies needed, including development tools, EPEL repository, and other
packages.
https://www.howtoforge.com/tutorial/how-to-install-nginx-with-rtmp-module-on-centos/ 2/20
14/3/2021 How to Install Nginx with RTMP Module on CentOS 7
In this step, we will download nginx source code with the additional dependencies including
pcre, zlib, and the OpenSSL.
cd /usr/local/src
wget https://nginx.org/download/nginx-1.14.0.tar.gz
tar -xzvf nginx-1.14.0.tar.gz
x
wget https://ftp.pcre.org/pub/pcre/pcre-8.42.zip
unzip pcre-8.42.zip
https://www.howtoforge.com/tutorial/how-to-install-nginx-with-rtmp-module-on-centos/ 3/20
14/3/2021 How to Install Nginx with RTMP Module on CentOS 7
wget https://www.zlib.net/zlib-1.2.11.tar.gz
tar -xzvf zlib-1.2.11.tar.gz
wget https://www.openssl.org/source/openssl-1.1.0h.tar.gz
tar -xzvf openssl-1.1.0h.tar.gz
Next, clone the Nginx RTMP Module source code using git command.
rm -f *.tar.gz *.zip
ls -lah
https://www.howtoforge.com/tutorial/how-to-install-nginx-with-rtmp-module-on-centos/ 4/20
14/3/2021 How to Install Nginx with RTMP Module on CentOS 7
cd nginx-1.14.0/
./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.14.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 \ x
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_degradation_module \
--with-http_slice_module \
--with-http_stub_status_module \
--http-log-path=/var/log/nginx/access.log \
--http-client-body-temp-path=/var/cache/nginx/client_temp \
https://www.howtoforge.com/tutorial/how-to-install-nginx-with-rtmp-module-on-centos/ 5/20
14/3/2021 How to Install Nginx with RTMP Module on CentOS 7
--http-proxy-temp-path=/var/cache/nginx/proxy_temp \ x
--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.42 \
--with-pcre-jit \
--with-zlib=../zlib-1.2.11 \
--with-openssl=../openssl-1.1.0h \
--with-openssl-opt=no-nextprotoneg \
--add-module=../nginx-rtmp-module \
--with-debug
Compile and install Nginx with RTMP module by running following commands.
sudo make
sudo make install
When the installation is complete, we need to create a new symlink module directory, create
a new nginx user and group, and create a new nginx cache directory.
Advertisement
https://www.howtoforge.com/tutorial/how-to-install-nginx-with-rtmp-module-on-centos/ 6/20
14/3/2021 How to Install Nginx with RTMP Module on CentOS 7
Now create a new Nginx cache directory '/var/cache/nginx' and change the owner of the
directory to 'nginx' user and group.
mkdir -p /var/cache/nginx/
chown -R nginx:nginx /var/cache/nginx/
nginx -t
nginx -V
https://www.howtoforge.com/tutorial/how-to-install-nginx-with-rtmp-module-on-centos/ 7/20
14/3/2021 How to Install Nginx with RTMP Module on CentOS 7
x
The Nginx web server has been installed on CentOS 7 with the RTMP Module enabled.
In this tutorial, we will be running nginx as a service and we need to create a new nginx
service file to the systemd service directory.
Go to the '/lib/systemd/system' directory and create a new 'nginx.service' file using vim.
cd /lib/systemd/system/
vim nginx.service
[Unit]
Description=nginx - high performance web server
Documentation=https://nginx.org/en/docs/
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target
[Service]
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
systemctl daemon-reload
Start the nginx service and enable it to launch everytime at system boot.
https://www.howtoforge.com/tutorial/how-to-install-nginx-with-rtmp-module-on-centos/ 8/20
14/3/2021 How to Install Nginx with RTMP Module on CentOS 7
In this step, we will create a new custom Nginx configuration for RTMP module.
Go to the '/etc/nginx' configuration directory and backup the original 'nginx.conf' file.
cd /etc/nginx/
mv nginx.conf nginx.conf.asli
vim nginx.conf
worker_processes auto;
events {
worker_connections 1024;
}
# RTMP configuration
rtmp {
server {
listen 1935; # Listen on standard RTMP port
chunk_size 4000;
https://www.howtoforge.com/tutorial/how-to-install-nginx-with-rtmp-module-on-centos/ 9/20
14/3/2021 How to Install Nginx with RTMP Module on CentOS 7
} x
}
http {
sendfile off;
tcp_nopush on;
aio on;
directio 512;
default_type application/octet-stream;
server {
listen 8080;
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';
types {
application/dash+xml mpd;
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
root /mnt/;
}
}
}
Next, we need to create a new directory for the HLS configuration and we've defined the
web root directory is on the '/mnt' directory.
Create the 'hls' directory under the '/mnt' directory and change the owner of the directory to
the nginx user and group.
mkdir -p /mnt/hls
chown -R nginx:nginx /mnt/hls
nginx -t
systemctl restart nginx
https://www.howtoforge.com/tutorial/how-to-install-nginx-with-rtmp-module-on-centos/ 10/20
14/3/2021 How to Install Nginx with RTMP Module on CentOS 7
In this tutorial, we will create new RTMP stream video on demand using the mp4 videos on
the server, and create a new live RTMP stream that will be broadcasted from the local
computer using the OBS software.
cd /etc/nginx/
vim nginx.conf
Now create a new directory 'mp4s' for storing all vod videos, and change the owner to the
nginx user group.
mkdir -p /mnt/mp4s
chown -R nginx:nginx /mnt/mp4s
Test nginx configuration and make sure there is no error, then restart the nginx service.
nginx -t
systemctl restart nginx
https://www.howtoforge.com/tutorial/how-to-install-nginx-with-rtmp-module-on-centos/ 11/20
14/3/2021 How to Install Nginx with RTMP Module on CentOS 7
x
Nginx configuration for the RTMP live stream and the vod stream has been completed.
Step 7 - Testing
Test RTMP live stream and vod stream using the VLC player.
rtmp://192.168.1.10:1935/vod/file.mp4
https://www.howtoforge.com/tutorial/how-to-install-nginx-with-rtmp-module-on-centos/ 12/20
14/3/2021 How to Install Nginx with RTMP Module on CentOS 7
In this tutorial, we will test the RTMP live stream using the obs software, and the vlc player.
We will stream only the terminal window using the open broadcaster software, and try to
watch the RTMP live stream using the VLC player.
x
rtmp://192.168.1.10:1935/stream/
And the following is the result of the live stream using open broadcaster through the nginx
rtmp module.
Installation of the Nginx web server with RTMP module on CentOS 7 has been completed
successfully.
Reference
https://github.com/sergey-dryabzhinsky/nginx-rtmp-module
https://www.howtoforge.com/tutorial/how-to-install-nginx-with-rtmp-module-on-centos/ 14/20
14/3/2021 How to Install Nginx with RTMP Module on CentOS 7
Suggested articles
16 Comment(s)
Add comment
Name * Email *
p
Submit comment
I'm not a robot
reCAPTCHA
Privacy - Terms
Comments
This tutorial worked out great, but I would like know how would one add streamer authentication, while this
works it also allows anyone to stream on my setup i d like to be able to restrict access
https://www.howtoforge.com/tutorial/how-to-install-nginx-with-rtmp-module-on-centos/ 15/20
14/3/2021 How to Install Nginx with RTMP Module on CentOS 7
Great post! How play the videos stored on /mnt/mp4s or /mnt/hls embeded in html?
I have done all right as what this article says, but still can't play video through vlc player.
By the way. The vlc player was installed on a Windows10 computer.
I try convert the rtmp stream to rtsp by using ffmpeg and it could successfuly parse the rtmp stream.
I don't know why my vlc player on windows os can't work. Could somebody help me.
Hello, I wanted to know which VPS server to hire, I need to know what configuration I need to use with 2000
thousand people watching my video simultaneously, thanks for the tutorial.
Works like a charm, except how can I view the stream from an embedded player from the net. Works in VLC
just fine, but I want the live stream to be viewed by others on my website.
I seem to have a problem streaming Live from OSB. Stream starts fine OSB connect to the server, stream
starts.
When I try using VLC to stream I just see the bar going back and forth, nothing happens, no errors on the
VLC side.
Any ides would be helpful.
Cheers,
Hubert
hello, I am looking to have someone build for me an HLS Streaming Server with NGINX so that I can do live
broadcasing on Roku IPTV.
I want to use my existing website to link the m3u8 link and run it through hoping that this may allow
unlimited viewers since i won't be saving any data. can anybody help? email me at trinityreseller@gmail.com
Hi,
I would like to use this to try out and create tutorial with in contacts. Can I do so?
https://www.howtoforge.com/tutorial/how-to-install-nginx-with-rtmp-module-on-centos/ 16/20
14/3/2021 How to Install Nginx with RTMP Module on CentOS 7
Hello ,
I have donw excectlly as it say
didn't get any error
but it doesn't work ,
when I enter the
serverIP:8080 , I get nothing
ServerIP:1935 nothing
the service is up
sudo systemctl status nginx
? nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2020-07-02 13:25:17 GMT; 32min ago
what could it be ?
Thanks,
Using CentOS 8 (Core) - All these steps work fanatstic except you now need to use nginx 1.15.0 instead of
1.14.0
wget https://nginx.org/download/nginx-1.15.0.tar.gztar -xzvf nginx-1.15.0.tar.gz
hls fragmented files deleted after a while i upload them to the server! in fact, after 1 min the converted files
deletes on the server!
RTMP TEST WORKS FINE ON VLC.
here is my ffmpeg command:
ffmpeg -i /mnt/videos/myfile.mp4 /mnt/hls/myfile.m3u8
.......here is my hls config:# Define the Applicationapplication show {live on;# Turn on HLShls on;hls_path
/mnt/hls/;hls_cleanup off;hls_playlist_length 10y;hls_fragment 3;......Any Idea!TNX.
https://www.howtoforge.com/tutorial/how-to-install-nginx-with-rtmp-module-on-centos/ 17/20
14/3/2021 How to Install Nginx with RTMP Module on CentOS 7
x
Sign up now!
Tutorial Info
https://www.howtoforge.com/tutorial/how-to-install-nginx-with-rtmp-module-on-centos/ 18/20
14/3/2021 How to Install Nginx with RTMP Module on CentOS 7
40.2k Followers
Popular Tutorials
RTMP Receiver
RTMP IP Camera
https://www.howtoforge.com/tutorial/how-to-install-nginx-with-rtmp-module-on-centos/ 19/20
14/3/2021 How to Install Nginx with RTMP Module on CentOS 7
___ x
report this ad
Xenforo skin by Xenfocus Contribute Contact Help Imprint and Legal Notice
https://www.howtoforge.com/tutorial/how-to-install-nginx-with-rtmp-module-on-centos/ 20/20