Created
          August 18, 2019 10:04 
        
      - 
      
 - 
        
Save UbuntuEvangelist/44fc83fe4cda4662a73394a9d04fdfc4 to your computer and use it in GitHub Desktop.  
    Seting up nginx+RTMP module on ubuntu 18.04 ▶️  to push the stream to multiple platforms
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | FIRST INSTALL THESE USEFUL / REQUIRED PACKAGES | |
| sudo apt-get install wget unzip software-properties-common dpkg-dev git make gcc automake build-essential zlib1g-dev libpcre3 libpcre3-dev libssl-dev libxslt1-dev libxml2-dev libgd-dev libgeoip-dev libgoogle-perftools-dev libperl-dev pkg-config autotools-dev gpac ffmpeg mediainfo mencoder lame libvorbisenc2 libvorbisfile3 libx264-dev libvo-aacenc-dev libmp3lame-dev libopus-dev unzip | |
| ADD THE NGINX REPOSITORY AND UPDATE | |
| sudo add-apt-repository ppa:nginx/stable | |
| apt update | |
| INSTALL NGINX | |
| sudo apt install nginx | |
| INSTALL THE RTMP MODULE | |
| sudo apt install libnginx-mod-rtmp | |
| CLONE THE RTMP GIT | |
| cd /usr/src | |
| git clone https://github.com/arut/nginx-rtmp-module | |
| COPY THE STAT.XSL FILE TO YOUR WEB FOLDER | |
| cp /usr/src/nginx-rtmp-module/stat.xsl /var/www/html/stat.xsl | |
| CREATE A NEW FILE CALLED CROSSDOMAIN.XML IN YOUR WEB FOLDER | |
| nano /var/www/html/crossdomain.xml | |
| PASTE THIS IN THE NEW FILE AND SAVE IT | |
| <?xml version="1.0"?> | |
| <!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd"> | |
| <cross-domain-policy> | |
| <allow-access-from domain="*"/> | |
| </cross-domain-policy> | |
| EDIT THE NGINX CONDIF FILE | |
| nano /etc/nginx/nginx.conf | |
| AT THE END OF THE FILE ADD THIS | |
| rtmp { | |
| server { | |
| listen 1935; | |
| chunk_size 4096; | |
| application live { | |
| live on; | |
| record off; | |
| interleave off; | |
| wait_key on; | |
| meta on; | |
| wait_video off; | |
| idle_streams off; | |
| sync 300ms; | |
| session_relay on; | |
| #allow publish 127.0.0.1; | |
| #allow publish 192.168.2.0/24; | |
| allow publish all; | |
| #deny publish all; | |
| allow play all; | |
| # EDIT THESE SO THE LIVESTREAM_KEY IS REPLACED BY YOUR PERSONAL KEY THAT YOU CAN LOOK UP ON THE SITE OF THE PLATFORM | |
| # push rtmp://live-ams.twitch.tv/app/LIVESTREAM_KEY; | |
| # push rtmp://a.rtmp.youtube.com/live2/LIVESTREAM_KEY; | |
| # push rtmp://ingest-ams.mixer.com:1935/beam/LIVESTREAM_KEY; | |
| } | |
| } | |
| } | |
| EDIT THE DEFAULT SITE CONFIG | |
| nano /etc/nginx/sites-enabled/default | |
| SEARCH FOR THE FOLLOWING LINES: | |
| #location ~ /\.ht { | |
| # deny all; | |
| AND DIRECTLY UNDER IT PASTE THE FOLLOWING | |
| location /stat { | |
| rtmp_stat all; | |
| rtmp_stat_stylesheet stat.xsl; | |
| } | |
| location /stat.xsl { | |
| root /var/www/html/; | |
| } | |
| #location /control { | |
| # you'll need a htpasswd auth file, that's outside the scope of this doc but any apache one will work | |
| # auth_basic "stream"; | |
| # rtmp_control all; | |
| #} | |
| SO THAT IT WILL LOOK SOMETHING LIKE THIS AFTER PASTING: | |
| # deny access to .htaccess files, if Apache's document root | |
| # concurs with nginx's one | |
| # | |
| #location ~ /\.ht { | |
| # deny all; | |
| #} | |
| location /stat { | |
| rtmp_stat all; | |
| rtmp_stat_stylesheet stat.xsl; | |
| } | |
| location /stat.xsl { | |
| root /var/www/html/; | |
| } | |
| #location /control { | |
| # you'll need a htpasswd auth file, that's outside the scope of this doc but any apache one will work | |
| # auth_basic "stream"; | |
| # rtmp_control all; | |
| #} | |
| } | |
| # Virtual Host configuration for example.com | |
| ------------------------------------------------------------ | |
| YOU ARE DONE SETTING UP THE SERVER. HAVE A LOOK AT THE WIKI FROM THE RTMP MODULE WEBPAGE TO LEARN HOW TO USE DIFFERENT VARIABLES TO FURTHER SET UP YOUR SERVER. https://github.com/arut/nginx-rtmp-module | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment