/etc/nginx/nginx.conf:76 中的未知指令“rtmp”

Jua*_* BG 3 nginx

我正在尝试启动服务器以通过网络摄像头进行串流,我是来自 Ubuntu 的一个相对较新的用户并安装 Nginx,现在,我尝试修改 nginx.conf 并配置 rtmp 服务器,这是我的脚本文件

user www-data;

worker_processes 4;

pid /run/nginx.pid;

events {

    worker_connections 768;

    # multi_accept on;
}

http {

    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    # server_tokens off;

    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    ##
    # Logging Settings
    ##

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    ##
    # Gzip Settings
    ##

    gzip on;
    gzip_disable "msie6";

    # gzip_vary on;
    # gzip_proxied any;
    # gzip_comp_level 6;
    # gzip_buffers 16 8k;
    # gzip_http_version 1.1;
    # gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

    ##
    # nginx-naxsi config
    ##
    # Uncomment it if you installed nginx-naxsi
    ##

    #include /etc/nginx/naxsi_core.rules;

    ##
    # nginx-passenger config
    ##
    # Uncomment it if you installed nginx-passenger
    ##

    #passenger_root /usr;
    #passenger_ruby /usr/bin/ruby;

    ##
    # Virtual Host Configs
    ##

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}


rtmp {

    server {

        listen 1935;

        chunk_size 8192;


        application vod {

            play /home/juanbg/vod ;

        }

        application live {

            live on;

            record off;

        }

    }

}
Run Code Online (Sandbox Code Playgroud)

为了修改它,我为 ubuntu 使用了 sublime text 3,我保存了文件,当我尝试在终端中运行 nginx 时,会发生这种情况:

juanbg@JuanBG:~$ sudo nginx
nginx: [emerg] unknown directive "rtmp" in /etc/nginx/nginx.conf:76
Run Code Online (Sandbox Code Playgroud)

我在这个网站和其他网站上阅读了所有类似的情况,一切都是问题,因为 rtmp 在 http (http{rtmp{}}) 的括号内,但在这种情况下不是,(或者我不知道)。

smi*_*e89 6

我知道这个问题已经很老了,但这可能对其他人有帮助。

为 rtmp 安装 nginx 时,程序必须从源代码编译。(例如,如此处所述

简而言之:

 sudo apt-get install build-essential libpcre3 libpcre3-dev libssl-dev
 wget http://nginx.org/download/nginx-1.9.2.tar.gz
 wget https://github.com/arut/nginx-rtmp-module/archive/master.zip
 unzip master.zip     
 tar -zxvf nginx-1.9.2.tar.gz
Run Code Online (Sandbox Code Playgroud)

如果您想使用来自http://nginx.org/download/的最新版本,请适当更改版本号。

 cd nginx-1.9.2
 ./configure --with-http_ssl_module --add-module=../nginx-rtmp-module-master
 make
 sudo make install
Run Code Online (Sandbox Code Playgroud)

现在必须更改 nginx.conf。

确保启动正确的二进制文件,which nginx在命令行上检查它。这应该指向/usr/local/nginx/sbin/nginx,否则 rtmp-module 是未知的。

开始: nginx

停止: nginx -s stop


小智 0

通过 homebrew 安装 nginx,如下http://brew.sh/homebrew-nginx/。确保使用该--with-rtmp-module标志。

另请注意,这将安装到/usr/local/etc/nginx