首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >/etc/nginx/nginx.conf中的未知指令"rtmp“:76

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

Stack Overflow用户
提问于 2016-05-26 00:23:26
回答 4查看 26.5K关注 0票数 3

我正在试着设置一个服务器来做摄像头监控,我是一个比较新的Ubuntu用户并且安装了Nginx,现在,我正在试着修改nginx.conf和配置rtmp服务器,这是我的脚本文件

代码语言:javascript
复制
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;

        }

    }

}

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

代码语言:javascript
复制
juanbg@JuanBG:~$ sudo nginx
nginx: [emerg] unknown directive "rtmp" in /etc/nginx/nginx.conf:76

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

EN

回答 4

Stack Overflow用户

发布于 2017-02-05 03:21:01

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

为rtmp安装nginx时,必须从源代码编译该程序。(e.g. as desecribed here)

简而言之:

代码语言:javascript
复制
 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

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

代码语言:javascript
复制
 cd nginx-1.9.2
 ./configure --with-http_ssl_module --add-module=../nginx-rtmp-module-master
 make
 sudo make install

现在必须更改nginx.conf。

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

开始:nginx

停止:nginx -s stop

票数 6
EN

Stack Overflow用户

发布于 2018-05-21 22:36:12

有一个类似的问题(尽管在另一个操作系统上):"nginx: emerg未知指令“rtmp在/usr/local/etc/nginx/rtmp-enabled/test.conf:2”中

代码语言:javascript
复制
# uname -ro
FreeBSD 11.1-RELEASE-p1
# nginx -V
nginx version: nginx/1.14.0
built with OpenSSL 1.0.2k-freebsd  26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/local/etc/nginx --with-cc-opt='-I /usr/local/include' --with-ld-opt='-L /usr/local/lib' --conf-path=/usr/local/etc/nginx/nginx.conf --sbin-path=/usr/local/sbin/nginx --pid-path=/var/run/nginx.pid --error-log-path=/var/log/nginx/error.log --user=www --group=www --modules-path=/usr/local/libexec/nginx --with-file-aio --with-threads --without-mail_imap_module --without-mail_pop3_module --without-mail_smtp_module --with-mail_ssl_module --http-client-body-temp-path=/var/tmp/nginx/client_body_temp --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi_temp --http-proxy-temp-path=/var/tmp/nginx/proxy_temp --http-scgi-temp-path=/var/tmp/nginx/scgi_temp --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi_temp --http-log-path=/var/log/nginx/access.log --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-pcre --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-stream_ssl_module --with-mail=dynamic --with-stream=dynamic --add-dynamic-module=/usr/ports/www/nginx/work/nginx-rtmp-module-1.2.1

这是我的工作:

make (make install )后,编辑config (/usr/local/etc/nginx/nginx.conf)并添加一行:

代码语言:javascript
复制
load_module /usr/local/libexec/nginx/ngx_rtmp_module.so;

对于Linux,库的路径将有所不同。

票数 1
EN

Stack Overflow用户

发布于 2021-10-08 17:15:28

在Ubuntu上,只需要安装rtmp模块即可。

sudo apt-get update

sudo apt-get install libnginx-mod-rtmp

sudo services nginx restart

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37442819

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档