我的操作系统信息:
uname -a
Linux vultr 5.10.0-13-amd64 #1 SMP Debian 5.10.106-1 (2022-03-17) x86_64 GNU/Linux
我已经libnginx-mod-rtmp
使用命令安装了模块
apt install libnginx-mod-rtmp
可以看到输出的信息:
Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /lib/systemd/system/nginx.service.
Setting up libnginx-mod-http-xslt-filter (1.18.0-6.1) ...
Setting up libnginx-mod-http-geoip (1.18.0-6.1) ...
Setting up libnginx-mod-rtmp (1.18.0-6.1) ...
Setting up libnginx-mod-mail (1.18.0-6.1) ...
Setting up libnginx-mod-http-image-filter (1.18.0-6.1) ...
Setting up libnginx-mod-stream (1.18.0-6.1) ...
Setting up libnginx-mod-stream-geoip (1.18.0-6.1) ...
Setting up nginx-core (1.18.0-6.1) ...
Upgrading binary: nginx.
Processing triggers for man-db (2.9.4-2) ...
Processing triggers for ufw (0.36-7.1) ...
现在在配置文件中设置 rmtp。
vim /etc/nginx/nginx.conf
rtmp {
server {
listen 1935;
chunk_size 4096;
allow publish 127.0.0.1;
deny publish all;
application live {
live on;
record off;
}
}
}
重新启动 nginx。
systemctl restart nginx
Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xe" for details.
systemctl status nginx
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/nginx.service.d
└─override.conf
Active: failed (Result: exit-code) since Wed 2022-05-04 08:14:19 CST; 16s ago
Docs: man:nginx(8)
Process: 96329 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)
CPU: 7ms
May 04 08:14:19 vultr systemd[1]: Starting A high performance web server and a reverse proxy server...
May 04 08:14:19 vultr nginx[96329]: nginx: [emerg] unknown directive "rtmp" in /etc/nginx/nginx.conf:85
May 04 08:14:19 vultr nginx[96329]: nginx: configuration file /etc/nginx/nginx.conf test failed
May 04 08:14:19 vultr systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
May 04 08:14:19 vultr systemd[1]: nginx.service: Failed with result 'exit-code'.
May 04 08:14:19 vultr systemd[1]: Failed to start A high performance web server and a reverse proxy server.
nginx -V
nginx version: nginx/1.18.0
built with OpenSSL 1.1.1k 25 Mar 2021 (running with OpenSSL 1.1.1n 15 Mar 2022)
TLS SNI support enabled
configure arguments: --with-cc-opt='-g -O2 -ffile-prefix-map=/build/nginx-q9LD4J/nginx-1.18.0=.
-fstack-protector-strong -Wformat -Werror=format-security
-fPIC -Wdate-time -D_FORTIFY_SOURCE=2'
--with-ld-opt='-Wl,-z,relro -Wl,-z,now -fPIC'
--prefix=/usr/share/nginx
--conf-path=/etc/nginx/nginx.conf
--http-log-path=/var/log/nginx/access.log
--error-log-path=/var/log/nginx/error.log
--lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid
--modules-path=/usr/lib/nginx/modules
--http-client-body-temp-path=/var/lib/nginx/body
--http-fastcgi-temp-path=/var/lib/nginx/fastcgi
--http-proxy-temp-path=/var/lib/nginx/proxy
--http-scgi-temp-path=/var/lib/nginx/scgi
--http-uwsgi-temp-path=/var/lib/nginx/uwsgi
--with-compat --with-debug --with-pcre-jit
--with-http_ssl_module --with-http_stub_status_module
--with-http_realip_module
--with-http_auth_request_module
--with-http_v2_module --with-http_dav_module
--with-http_slice_module --with-threads
--with-http_addition_module
--with-http_gunzip_module --with-http_gzip_static_module
--with-http_sub_module
如何解决这个问题?
答案1
起初我以为你必须使用包含的模块来构建 nginx,但通过 apt install 执行时似乎不需要这样做。
您可能必须手动加载模块(检查模块目录中是否存在该模块):
load_module "modules/ngx_rtmp_module.so";
我看到的另一个目录提到:
load_module /usr/local/libexec/nginx/ngx_rtmp_module.so;