我正在尝试通过网络摄像头启动服务器,我是来自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;
}
}
}
为了修改这个,我使用了sublime text 3 for ubuntu,我保存了文件,当我尝试在终端中运行nginx时,这就发生了:
juanbg@JuanBG:~$ sudo nginx
nginx: [emerg] unknown directive "rtmp" in /etc/nginx/nginx.conf:76
我在本网站及其他网站上阅读了所有类似情况,并且一切都是问题,因为rtmp在http(http {rtmp {}})的括号内,但在这种情况下不是,(或者我不知道)。 / p>
答案 0 :(得分:2)
我知道这个问题已经很老了,但这可能对其他人有帮助。
为rtmp安装nginx时,必须从源代码编译程序。 (e.g. as desecribed here)
简而言之:
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/中的最新版本,请更改相应的版本号。
cd nginx-1.9.2
./configure --with-http_ssl_module --add-module=../nginx-rtmp-module-master
make
sudo make install
现在必须更改nginx.conf。
确保启动正确的二进制文件,在命令行上使用which nginx
进行检查。这应该指向/usr/local/nginx/sbin/nginx
,否则rtmp-module是未知的。
开始:nginx
停止:nginx -s stop
答案 1 :(得分:1)
有一个类似的问题(虽然在另一个操作系统上): " nginx:[emerg]未知指令" rtmp"在/usr/local/etc/nginx/rtmp-enabled/test.conf:2"
var scrolll = function() {
var elmnt = document.getElementsByClassName("scnd")[0];
elmnt.scrollLeft += 50;
}
它为我工作:
make(make install clean)后,编辑config(/usr/local/etc/nginx/nginx.conf)并添加一行:
# 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
对于Linux,库的路径会有所不同。
答案 2 :(得分:0)
通过homebrew follwing http://brew.sh/homebrew-nginx/安装nginx。请务必使用--with-rtmp-module
标记。
另请注意,这会安装到/usr/local/etc/nginx