# statistics and reporting experience >

How To Install Nginx 1.18.0 with RTMP Module on CentOS 7

How To Install Nginx 1.18.0 RTMP HLS CentOS 7

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.

####################################
        install Centos 7
####################################

$ yum install curl wget nano git net-tools -y
$ yum install openssh-server openssh-clients -y

$ systemctl start sshd

$ nano /etc/ssh/sshd_config

$ edit PermitRootLogin yes

$ yum install epel-release -y
$ yum groupinstall "Development Tools" -y
$ yum install perl perl-devel perl-ExtUtils-Embed libxslt libxslt-devel -y
$ yum install libxml2 libxml2-devel gd gd-devel GeoIP GeoIP-devel -y

https://docs.nginx.com/nginx/admin-guide/installing-nginx/installing-nginx-open-source/

####################################
        Downloading Sources
####################################

$ wget https://nginx.org/download/nginx-1.18.0.tar.gz && tar zxvf nginx-1.18.0.tar.gz
$ wget https://ftp.pcre.org/pub/pcre/pcre-8.44.tar.gz && tar xzvf pcre-8.44.tar.gz
$ 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.1g.tar.gz && tar xzvf openssl-1.1.1g.tar.gz
$ git clone git://github.com/arut/nginx-rtmp-module.git

$ rm -rf *.tar.gz

$ cd ~/nginx-1.18.0

./configure --add-module=../nginx-rtmp-module \
            --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-stream_ssl_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 \
            --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.1g \
            --with-openssl-opt=no-nextprotoneg \
            --with-debug

$ make 
$ make install

######################
Add User Centos7 Nginx
######################

$ useradd --system --home /var/lib/nginx --shell /sbin/nologin --comment "nginx system user" nginx
$ mkdir -p /var/cache/nginx
$ chown nginx:nginx /var/cache/nginx

###############################
Add Start Service Nginx
###############################

$ nano /lib/systemd/system/nginx.service 

[Unit]
Description=nginx - high performance web server
Documentation=https://nginx.org/en/docs/
After=network.target remote-fs.target nss-lookup.target
Wants=network-online.target
[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStartPre=/usr/bin/rm -f /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
KillSignal=SIGQUIT
TimeoutStopSec=5
KillMode=process
PrivateTmp=true
[Install]
WantedBy=multi-user.target

########################
Create Systemctl Service
########################

$ systemctl daemon-reload
$ systemctl start nginx
$ systemctl enable nginx
$ systemctl restart nginx
$ systemctl status nginx

###############
Configure Nginx
###############
$nano /etc/nginx/nginx.conf

$ firewall-cmd --permanent --add-port=80/tcp
$ firewall-cmd --permanent --add-port=443/tcp
$ firewall-cmd --permanent --add-port=1935/tcp
$ firewall-cmd --reload 

ในบทเป็นวิธีการติดตั้งและกำหนดค่าเว็บเซิร์ฟเวอร์ Nginx ด้วยโมดูล RTMP เราจะใช้เซิร์ฟเวอร์ที่ติดตั้ง CentOS 7 ล่าสุดและคู่มือนี้จะรวมถึงการกำหนดค่าของโมดูล nginx และ rtmp และการสร้างสตรีมสด RTMP และวิดีโอตามความต้องการ

Share on facebook
Facebook
Share on google
Google+
Share on twitter
Twitter
Share on linkedin
LinkedIn
Share on pinterest
Pinterest