{"id":6932,"date":"2018-09-27T20:46:26","date_gmt":"2018-09-27T17:46:26","guid":{"rendered":"https:\/\/www.howtoforge.com\/tutorial\/how-to-install-nginx-with-rtmp-module-on-centos\/"},"modified":"2018-09-27T20:46:26","modified_gmt":"2018-09-27T17:46:26","slug":"how-to-install-nginx-with-rtmp-module-on-centos-7","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/how-to-install-nginx-with-rtmp-module-on-centos-7\/","title":{"rendered":"How to Install Nginx with RTMP Module on CentOS 7"},"content":{"rendered":"<p>RTMP (Real Time Messaging Protocol) is a high-performance protocol for transmission of data, audio, and video over the internet between flash-based platform technologies. Originally developed by Macromedia, and now owned by Adobe.<\/p>\n<p>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.<\/p>\n<p>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.<\/p>\n<h2 id=\"prerequisites\">Prerequisites<\/h2>\n<ul>\n<li>CentOS 7 Server<\/li>\n<li>Root privileges<\/li>\n<\/ul>\n<h2 id=\"what-we-will-do\">What we will do?<\/h2>\n<ol>\n<li>Install Dependencies<\/li>\n<li>Download Nginx with Additional Package and RTMP Module<\/li>\n<li>Compile Nginx and Install from Source<\/li>\n<li>Configure Nginx as a Service<\/li>\n<li>Configure Nginx RTMP Module<\/li>\n<li>Setup First RTMP Live Stream<\/li>\n<li>Testing<\/li>\n<\/ol>\n<h2 id=\"step-install-dependencies\">Step 1 &#8211; Install Dependencies<\/h2>\n<p>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.<\/p>\n<p>Install CentOS &#8216;Development Tools&#8217;.<\/p>\n<p class=\"command\">sudo yum -y groupinstall &#8216;Development Tools&#8217;<\/p>\n<p>Add the EPEL repository.<\/p>\n<p class=\"command\">sudo yum -y install epel-release<\/p>\n<p>Install Nginx dependencies.<\/p>\n<p class=\"command\">sudo yum install -y\u00a0 wget git unzip perl perl-devel perl-ExtUtils-Embed libxslt libxslt-devel libxml2 libxml2-devel gd gd-devel pcre-devel GeoIP GeoIP-devel<\/p>\n<p>Wait for all packages installed.<\/p>\n<p><a class=\"fancybox\" id=\"img-1\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_nginx_with_rtmp_module_on_centos_7\/big\/1.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/09\/how-to-install-nginx-with-rtmp-module-on-centos-7.png\" alt=\"Install Nginx and RTMP dependencies\" width=\"500\" height=\"250\" title=\"\"><\/a><\/p>\n<h2 id=\"step-download-nginx-with-additional-package-and-rtmp-module\">Step 2 &#8211; Download Nginx with Additional Package and RTMP Module<\/h2>\n<p>In this step, we will download nginx source code with the additional dependencies including pcre, zlib, and the OpenSSL.<\/p>\n<p>Go to the &#8216;\/usr\/local\/src&#8217; directory.<\/p>\n<p class=\"command\">cd \/usr\/local\/src<\/p>\n<p>Download Nginx 1.14.0 and extract it.<\/p>\n<p class=\"command\">wget https:\/\/nginx.org\/download\/nginx-1.14.0.tar.gz<br \/>tar -xzvf nginx-1.14.0.tar.gz<\/p>\n<p>Download the pcre package and extract it.<\/p>\n<p class=\"command\">wget https:\/\/ftp.pcre.org\/pub\/pcre\/pcre-8.42.zip<br \/>unzip pcre-8.42.zip<\/p>\n<p>Download the zlib package and extract it.<\/p>\n<p class=\"command\">wget https:\/\/www.zlib.net\/zlib-1.2.11.tar.gz<br \/>tar -xzvf zlib-1.2.11.tar.gz<\/p>\n<p>Download the OpenSSL package and extract it.<\/p>\n<p class=\"command\">wget https:\/\/www.openssl.org\/source\/openssl-1.1.0h.tar.gz<br \/>tar -xzvf openssl-1.1.0h.tar.gz<\/p>\n<p>Next, clone the Nginx RTMP Module source code using git command.<\/p>\n<p class=\"command\">git clone https:\/\/github.com\/sergey-dryabzhinsky\/nginx-rtmp-module.git<\/p>\n<p>And remove all compressed tar.gz and .zip files.<\/p>\n<p class=\"command\">rm -f *.tar.gz *.zip<\/p>\n<p>Following are the directory details we have.<\/p>\n<p class=\"command\">ls -lah<\/p>\n<p><a class=\"fancybox\" id=\"img-2\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_nginx_with_rtmp_module_on_centos_7\/big\/2.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/09\/how-to-install-nginx-with-rtmp-module-on-centos-7-1.png\" alt=\"Nginx sources downloaded\" width=\"500\" height=\"169\" title=\"\"><\/a><\/p>\n<p>And we&#8217;re ready to compile and install.<\/p>\n<h2 id=\"step-compile-nginx-and-install-from-source\">Step 3 &#8211; Compile Nginx and Install from Source<\/h2>\n<p>Go to the &#8216;nginx-1.14.0&#8217; directory.<\/p>\n<p class=\"command\">cd nginx-1.14.0\/<\/p>\n<p>Configure the nginx 1.14.0 using those parameters below.<\/p>\n<p class=\"command\">.\/configure &#8211;prefix=\/etc\/nginx \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;sbin-path=\/usr\/sbin\/nginx \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;modules-path=\/usr\/lib64\/nginx\/modules \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;conf-path=\/etc\/nginx\/nginx.conf \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;error-log-path=\/var\/log\/nginx\/error.log \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;pid-path=\/var\/run\/nginx.pid \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;lock-path=\/var\/run\/nginx.lock \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;user=nginx \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;group=nginx \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;build=CentOS \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;builddir=nginx-1.14.0 \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;with-select_module \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;with-poll_module \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;with-threads \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;with-file-aio \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;with-http_ssl_module \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;with-http_v2_module \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;with-http_realip_module \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;with-http_addition_module \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;with-http_xslt_module=dynamic \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;with-http_image_filter_module=dynamic \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;with-http_geoip_module=dynamic \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;with-http_sub_module \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;with-http_dav_module \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;with-http_flv_module \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;with-http_mp4_module \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;with-http_gunzip_module \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;with-http_gzip_static_module \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;with-http_auth_request_module \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;with-http_random_index_module \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;with-http_secure_link_module \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;with-http_degradation_module \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;with-http_slice_module \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;with-http_stub_status_module \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;http-log-path=\/var\/log\/nginx\/access.log \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;http-client-body-temp-path=\/var\/cache\/nginx\/client_temp \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;http-proxy-temp-path=\/var\/cache\/nginx\/proxy_temp \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;http-fastcgi-temp-path=\/var\/cache\/nginx\/fastcgi_temp \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;http-uwsgi-temp-path=\/var\/cache\/nginx\/uwsgi_temp \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;http-scgi-temp-path=\/var\/cache\/nginx\/scgi_temp \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;with-mail=dynamic \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;with-mail_ssl_module \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;with-stream=dynamic \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;with-stream_ssl_module \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;with-stream_realip_module \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;with-stream_geoip_module=dynamic \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;with-stream_ssl_preread_module \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;with-compat \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;with-pcre=..\/pcre-8.42 \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;with-pcre-jit \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;with-zlib=..\/zlib-1.2.11 \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;with-openssl=..\/openssl-1.1.0h \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;with-openssl-opt=no-nextprotoneg \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;add-module=..\/nginx-rtmp-module \\<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;with-debug<\/p>\n<p><a class=\"fancybox\" id=\"img-3\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_nginx_with_rtmp_module_on_centos_7\/big\/3.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/09\/how-to-install-nginx-with-rtmp-module-on-centos-7-2.png\" alt=\"Compile nginx\" width=\"500\" height=\"275\" title=\"\"><\/a><\/p>\n<p>Compile and install Nginx with RTMP module by running following commands.<\/p>\n<p class=\"command\">sudo make<br \/>sudo make install<\/p>\n<p>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.<\/p>\n<p>Create nginx symlink module to the &#8216;\/etc\/nginx&#8217; configuration directory.<\/p>\n<p class=\"command\">sudo ln -s \/usr\/lib64\/nginx\/modules \/etc\/nginx\/modules<\/p>\n<p>Create a new &#8216;nginx&#8217; system user and group.<\/p>\n<p class=\"command\">sudo useradd -r -d \/var\/cache\/nginx\/ -s \/sbin\/nologin -U nginx<\/p>\n<p>Now create a new Nginx cache directory &#8216;\/var\/cache\/nginx&#8217; and change the owner of the directory to &#8216;nginx&#8217; user and group.<\/p>\n<p class=\"command\">mkdir -p \/var\/cache\/nginx\/<br \/>chown -R nginx:nginx \/var\/cache\/nginx\/<\/p>\n<p>Test nginx configuration and the installed nginx version.<\/p>\n<p class=\"command\">nginx -t<br \/>nginx -V<\/p>\n<p>And the following is the result.<\/p>\n<p><a class=\"fancybox\" id=\"img-4\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_nginx_with_rtmp_module_on_centos_7\/big\/4.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/09\/how-to-install-nginx-with-rtmp-module-on-centos-7-3.png\" alt=\"Nginx compiled successfully\" width=\"500\" height=\"190\" title=\"\"><\/a><\/p>\n<p>The Nginx web server has been installed on CentOS 7 with the RTMP Module enabled.<\/p>\n<h2 id=\"step-configure-nginx-as-a-service\">Step 4 &#8211; Configure Nginx as a Service<\/h2>\n<p>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.<\/p>\n<p>Go to the &#8216;\/lib\/systemd\/system&#8217; directory and create a new &#8216;nginx.service&#8217; file using <a href=\"https:\/\/www.howtoforge.com\/vim-basics\" target=\"_blank\" rel=\"noopener noreferrer\">vim<\/a>.<\/p>\n<p class=\"command\">cd \/lib\/systemd\/system\/<br \/>vim nginx.service<\/p>\n<p>paste the configuration below.<\/p>\n<pre>[Unit]&#13;\nDescription=nginx - high performance web server&#13;\nDocumentation=https:\/\/nginx.org\/en\/docs\/&#13;\nAfter=network-online.target remote-fs.target nss-lookup.target&#13;\nWants=network-online.target&#13;\n&#13;\n[Service]&#13;\nType=forking&#13;\nPIDFile=\/var\/run\/nginx.pid&#13;\nExecStartPre=\/usr\/sbin\/nginx -t -c \/etc\/nginx\/nginx.conf&#13;\nExecStart=\/usr\/sbin\/nginx -c \/etc\/nginx\/nginx.conf&#13;\nExecReload=\/bin\/kill -s HUP $MAINPID&#13;\nExecStop=\/bin\/kill -s TERM $MAINPID&#13;\n&#13;\n[Install]&#13;\nWantedBy=multi-user.target&#13;\n<\/pre>\n<p>Save and exit.<\/p>\n<p>Now reload the systemd system.<\/p>\n<p class=\"command\">systemctl daemon-reload<\/p>\n<p>Start the nginx service and enable it to launch everytime at system boot.<\/p>\n<p class=\"command\">systemctl start nginx<br \/>systemctl enable nginx<\/p>\n<p>The Nginx web server is up and running as a service on CentOS 7 system.<\/p>\n<p><a class=\"fancybox\" id=\"img-5\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_nginx_with_rtmp_module_on_centos_7\/big\/5.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/09\/how-to-install-nginx-with-rtmp-module-on-centos-7-4.png\" alt=\"Nginx systemd service\" width=\"500\" height=\"226\" title=\"\"><\/a><\/p>\n<h2 id=\"step-configure-nginx-rtmp-module\">Step 5 &#8211; Configure Nginx RTMP Module<\/h2>\n<p>In this step, we will create a new custom Nginx configuration for RTMP module.<\/p>\n<p>Go to the &#8216;\/etc\/nginx&#8217; configuration directory and backup the original &#8216;nginx.conf&#8217; file.<\/p>\n<p class=\"command\">cd \/etc\/nginx\/<br \/>mv nginx.conf nginx.conf.asli<\/p>\n<p>Now create a custom configuration &#8216;nginx.conf&#8217;.<\/p>\n<p class=\"command\">vim nginx.conf<\/p>\n<p>Paste Nginx RTMP configuration below.<\/p>\n<pre>worker_processes auto;&#13;\nevents {&#13; worker_connections 1024;&#13;\n}&#13;\n&#13;\n# RTMP configuration&#13;\nrtmp {&#13; server {&#13; listen 1935; # Listen on standard RTMP port&#13; chunk_size 4000;&#13;\n&#13;\n# Define the Application&#13; application show {&#13; live on;&#13; # Turn on HLS&#13; hls on;&#13; hls_path \/mnt\/hls\/;&#13; hls_fragment 3;&#13; hls_playlist_length 60;&#13; # disable consuming the stream from nginx as rtmp&#13; deny play all;&#13; }&#13;\n&#13; }&#13;\n}&#13;\n&#13;\nhttp {&#13; sendfile off;&#13; tcp_nopush on;&#13; aio on;&#13; directio 512;&#13; default_type application\/octet-stream;&#13;\n&#13; server {&#13; listen 8080;&#13;\n&#13; location \/ {&#13; # Disable cache&#13; add_header 'Cache-Control' 'no-cache';&#13;\n&#13; # CORS setup&#13; add_header 'Access-Control-Allow-Origin' '*' always;&#13; add_header 'Access-Control-Expose-Headers' 'Content-Length';&#13;\n&#13; # allow CORS preflight requests&#13; if ($request_method = 'OPTIONS') {&#13; add_header 'Access-Control-Allow-Origin' '*';&#13; add_header 'Access-Control-Max-Age' 1728000;&#13; add_header 'Content-Type' 'text\/plain charset=UTF-8';&#13; add_header 'Content-Length' 0;&#13; return 204;&#13; }&#13;\n&#13; types {&#13; application\/dash+xml mpd;&#13; application\/vnd.apple.mpegurl m3u8;&#13; video\/mp2t ts;&#13; }&#13;\n&#13; root \/mnt\/;&#13; }&#13; }&#13;\n}<\/pre>\n<p>Save and exit.<\/p>\n<p>Next, we need to create a new directory for the HLS configuration and we&#8217;ve defined the web root directory is on the &#8216;\/mnt&#8217; directory.<\/p>\n<p>Create the &#8216;hls&#8217; directory under the &#8216;\/mnt&#8217; directory and change the owner of the directory to the nginx user and group.<\/p>\n<p class=\"command\">mkdir -p \/mnt\/hls<br \/>chown -R nginx:nginx \/mnt\/hls<\/p>\n<p>Test the configuration and restart the nginx service.<\/p>\n<p class=\"command\">nginx -t<br \/>systemctl restart nginx<\/p>\n<p><a class=\"fancybox\" id=\"img-6\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_nginx_with_rtmp_module_on_centos_7\/big\/6.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/09\/how-to-install-nginx-with-rtmp-module-on-centos-7-5.png\" alt=\"Configure Nginx for RTMP\" width=\"500\" height=\"190\" title=\"\"><\/a><\/p>\n<h2 id=\"step-setup-first-rtmp-live-stream\">Step 6 &#8211; Setup First RTMP Live Stream<\/h2>\n<p>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.<\/p>\n<p>Go to the &#8216;\/etc\/nginx&#8217; configuration directory and edit the &#8216;nginx.conf&#8217; file.<\/p>\n<p class=\"command\">cd \/etc\/nginx\/<br \/>vim nginx.conf<\/p>\n<p>Paste configurations below in to the &#8216;rtmp { &#8230; }&#8217; bracket.<\/p>\n<pre> # RTMP video on demand for mp4 files&#13; application vod {&#13; play \/mnt\/mp4s;&#13; }&#13;\n&#13; # RTMP stream using OBS&#13; application stream {&#13; live on;&#13; }<\/pre>\n<p>Save and exit.<\/p>\n<p>Now create a new directory &#8216;mp4s&#8217; for storing all vod videos, and change the owner to the nginx user group.<\/p>\n<p class=\"command\">mkdir -p \/mnt\/mp4s<br \/>chown -R nginx:nginx \/mnt\/mp4s<\/p>\n<p>Test nginx configuration and make sure there is no error, then restart the nginx service.<\/p>\n<p class=\"command\">nginx -t<br \/>systemctl restart nginx<\/p>\n<p>Nginx configuration for the RTMP live stream and the vod stream has been completed.<\/p>\n<p><a class=\"fancybox\" id=\"img-7\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_nginx_with_rtmp_module_on_centos_7\/big\/7.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/09\/how-to-install-nginx-with-rtmp-module-on-centos-7-6.png\" alt=\"Setup RTMP live stream\" width=\"500\" height=\"161\" title=\"\"><\/a><\/p>\n<h2 id=\"step-testing\">Step 7 &#8211; Testing<\/h2>\n<p>Test RTMP live stream and vod stream using the VLC player.<\/p>\n<h3 id=\"video-on-demand-stream\">Video On Demand Stream<\/h3>\n<p>Open the VLC app on your computer.<\/p>\n<p>Click the &#8216;File&#8217; menu choose the &#8216;Open Network&#8217; option.<\/p>\n<p>Now type the RTMP URL for our vod stream.<\/p>\n<p><em><strong>rtmp:\/\/192.168.1.10:1935\/vod\/file.mp4<\/strong><\/em><\/p>\n<p>Click the &#8216;Open&#8217; button.<\/p>\n<p><a class=\"fancybox\" id=\"img-8\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_nginx_with_rtmp_module_on_centos_7\/big\/8.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/09\/how-to-install-nginx-with-rtmp-module-on-centos-7-7.png\" alt=\"RTMP client setup\" width=\"500\" height=\"271\" title=\"\"><\/a><\/p>\n<p>And the following are the results of the video stream.<\/p>\n<p><a class=\"fancybox\" id=\"img-9\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_nginx_with_rtmp_module_on_centos_7\/big\/9.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/09\/how-to-install-nginx-with-rtmp-module-on-centos-7-8.png\" alt=\"RTMP Video Stream\" width=\"500\" height=\"308\" title=\"\"><\/a><\/p>\n<h3 id=\"live-stream-using-obs-open-broadcaster-software\">Live Stream using OBS (Open Broadcaster Software)<\/h3>\n<p>In this tutorial, we will test the RTMP live stream using the obs software, and the vlc player.<\/p>\n<p>We will stream only the terminal window using the open broadcaster software, and try to watch the RTMP live stream using the VLC player.<\/p>\n<p>Following is my configuration for the obs software.<\/p>\n<p><a class=\"fancybox\" id=\"img-12\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_nginx_with_rtmp_module_on_centos_7\/big\/12.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/09\/how-to-install-nginx-with-rtmp-module-on-centos-7-9.png\" alt=\"Live Stream using OBS (Open Broadcaster Software)\" width=\"500\" height=\"380\" title=\"\"><\/a><\/p>\n<p>Open the VLC app on your computer.<\/p>\n<p>Click the &#8216;File&#8217; menu, choose the &#8216;Open Network&#8217; option.<\/p>\n<p>Now type the RTMP URL for our live stream.<\/p>\n<p>rtmp<em><strong>:\/\/192.168.1.10:1935\/stream\/<\/strong><\/em><\/p>\n<p>Click the &#8216;Open&#8217; button.<\/p>\n<p><a class=\"fancybox\" id=\"img-10\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_nginx_with_rtmp_module_on_centos_7\/big\/10.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/09\/how-to-install-nginx-with-rtmp-module-on-centos-7-10.png\" alt=\"Live stream configuration\" width=\"500\" height=\"271\" title=\"\"><\/a><\/p>\n<p>And the following is the result of the live stream using open broadcaster through the nginx rtmp module.<\/p>\n<p><a class=\"fancybox\" id=\"img-11\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_nginx_with_rtmp_module_on_centos_7\/big\/11.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/09\/how-to-install-nginx-with-rtmp-module-on-centos-7-11.png\" alt=\"Live stream sows up in Media client\" width=\"500\" height=\"338\" title=\"\"><\/a><\/p>\n<p>Installation of the Nginx web server with RTMP module on CentOS 7 has been completed successfully.<\/p>\n<h2 id=\"reference\">Reference<\/h2>\n<div class=\"authorbox\" readability=\"15\">\n<p><strong>About Muhammad Arul<\/strong><\/p>\n<p>Muhammad Arul is a freelance system administrator and technical writer. He is working with Linux Environments for more than 5 years, an Open Source enthusiast and highly motivated on Linux installation and troubleshooting. Mostly working with RedHat\/CentOS Linux and Ubuntu\/Debian, Nginx and Apache web server, Proxmox, Zimbra Administration, and Website Optimization. Currently learning about OpenStack and Container Technology.<\/p>\n<\/div>\n<div>\n<p><b>Share this page:<\/b><\/p>\n<p>\n<a href=\"https:\/\/www.facebook.com\/sharer.php?u=https%3A%2F%2Fwww.howtoforge.com%2Ftutorial%2Fhow-to-install-nginx-with-rtmp-module-on-centos%2F\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/09\/how-to-install-nginx-with-rtmp-module-on-centos-7-12.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/twitter.com\/intent\/tweet?url=https%3A%2F%2Fwww.howtoforge.com%2Ftutorial%2Fhow-to-install-nginx-with-rtmp-module-on-centos%2F&amp;text=How+to+Install+Nginx+with+RTMP+Module+on+CentOS+7&amp;via=howtoforgecom&amp;related=howtoforgecom\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/09\/how-to-install-nginx-with-rtmp-module-on-centos-7-13.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/twitter.com\/howtoforgecom\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/09\/how-to-install-nginx-with-rtmp-module-on-centos-7-14.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/plus.google.com\/share?url=https%3A%2F%2Fwww.howtoforge.com%2Ftutorial%2Fhow-to-install-nginx-with-rtmp-module-on-centos%2F\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/09\/how-to-install-nginx-with-rtmp-module-on-centos-7-15.png\" height=\"20\" alt=\"\" title=\"\"><\/a>\n<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>RTMP (Real Time Messaging Protocol) is a high-performance protocol for transmission of data, audio, and video over the internet between flash-based platform technologies. Originally developed by Macromedia, and now owned by Adobe. 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 &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[],"class_list":["post-6932","post","type-post","status-publish","format-standard","hentry","category-36"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/6932","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/comments?post=6932"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/6932\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=6932"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=6932"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=6932"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}