无法启动 Nginx,Brotli 配置错误

无法启动 Nginx,Brotli 配置错误

我在 Debian 9 操作系统上设置了一个 nginx 服务器作为 apache2 的反向代理。Apache2 在 80 以外的其他端口上运行。我尝试使用 certbot 更新我的站点证书,并在该过程中的某个地方运行了此命令:

$ sudo apt install python3-certbot-nginx

我认为这在我的计算机上安装了一份全新的 nginx 服务器副本(如果我错了请纠正我),从那时起 nginx 就无法启动了。以下是测试命令的结果:

nginx -t

nginx: [emerg] dlopen() "/usr/share/nginx/nginx/modules/ngx_http_brotli_filter_module.so" failed (/usr/share/nginx/nginx/modules/ngx_http_brotli_filter_module.so: cann
ot open shared object file: No such file or directory) in /etc/nginx/modules.conf.d/brotli.conf:2
nginx: configuration file /etc/nginx/nginx.conf test failed

nginx -V

nginx version: nginx/1.10.3
built with OpenSSL 1.1.0l  10 Sep 2019
TLS SNI support enabled
configure arguments: --with-cc-opt='-g -O2 -fdebug-prefix-map=/build/nginx-8G38mz/nginx-1.10.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time 
-D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-z,relro -Wl,-z,now' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --er
ror-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=/va
r/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-tem
p-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_r
equest_module --with-http_v2_module --with-http_dav_module --with-http_slice_module --with-threads --with-http_addition_module --with-http_geoip_module=dynamic --with-
http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic --with-http_sub_module --with-http_xslt_module=dynamic --with-stream=dynamic 
--with-stream_ssl_module --with-mail=dynamic --with-mail_ssl_module --add-dynamic-module=/build/nginx-8G38mz/nginx-1.10.3/debian/modules/nginx-auth-pam --add-dynamic-m
odule=/build/nginx-8G38mz/nginx-1.10.3/debian/modules/nginx-dav-ext-module --add-dynamic-module=/build/nginx-8G38mz/nginx-1.10.3/debian/modules/nginx-echo --add-dynami
c-module=/build/nginx-8G38mz/nginx-1.10.3/debian/modules/nginx-upstream-fair --add-dynamic-module=/build/nginx-8G38mz/nginx-1.10.3/debian/modules/ngx_http_substitution
s_filter_module

sudo 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)
   Active: failed (Result: exit-code) since Mon 2022-04-11 01:20:12 CEST; 14min ago
     Docs: man:nginnginx: [emerg] dlopen() "/usr/share/nginx/nginx/modules/ngx_http_brotli_filter_module.so" failed (/usr/share/nginx/nginx/modules/ngx_http_brotli_filter_module.so: cann
ot open shared object file: No such file or directory) in /etc/nginx/modules.conf.d/brotli.conf:2
nginx: configuration file /etc/nginx/nginx.conf test failedx(8)
  Process: 22395 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)
Apr 11 01:20:12 cp-com-vm systemd[1]: Starting A high performance web server and a reverse proxy server...
Apr 11 01:20:12 cp-com-vm nginx[22395]: nginx: [emerg] dlopen() "/usr/share/nginx/nginx/modules/ngx_http_brotli_filter_module.so" failed (/usr/share/nginx/nginx/module
Apr 11 01:20:12 cp-com-vm nginx[22395]: nginx: configuration file /etc/nginx/nginx.conf test failed
Apr 11 01:20:12 cp-com-vm systemd[1]: nginx.service: Control process exited, code=exited status=1
Apr 11 01:20:12 cp-com-vm systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Apr 11 01:20:12 cp-com-vm systemd[1]: nginx.service: Unit entered failed state.
Apr 11 01:20:12 cp-com-vm systemd[1]: nginx.service: Failed with result 'exit-code'.

nginx.conf

   #user  nginx;
 worker_processes  1;

#error_log  /var/log/nginx/error.log;
 #error_log  /var/log/nginx/error.log  notice;
#error_log  /var/log/nginx/error.log  info;

 #pid        /var/run/nginx.pid;

 include /etc/nginx/modules.conf.d/*.conf;

events {
worker_connections  1024;
}

 http {
include       mime.types;
default_type  application/octet-stream;

#log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
#                  '$status $body_bytes_sent "$http_referer" '
#                  '"$http_user_agent" "$http_x_forwarded_for"';

#access_log  /var/log/nginx/access.log  main;

sendfile        on;
#tcp_nopush     on;

#keepalive_timeout  0;
keepalive_timeout  65;
#tcp_nodelay        on;

#gzip  on;
#gzip_disable "MSIE [1-6]\.(?!.*SV1)";

server_tokens off;

include /etc/nginx/conf.d/*.conf;
client_max_body_size 512M;
}

# override global parameters e.g. worker_rlimit_nofile
include /etc/nginx/*global_params;

brotli.conf

load_module nginx/modules/ngx_http_brotli_filter_module.so;
load_module nginx/modules/ngx_http_brotli_static_module.so;

我尝试了不同网站上的许多关于如何恢复服务器的答案,但都无济于事,有人能指出确切的问题吗?仅供参考 - 我之后能够续订证书,所以现在只剩下这个问题了。TIA

答案1

无论我怎么尝试,我都无法修复我当时安装的 nginx。尽管我单独安装了 brotli 并尝试在配置中注释它,但我的 nginx.conf 总是失败。

我必须清除 nginx 实例并重新安装它才能使其重新启动并运行:

apt-get purge nginx nginx-common nginx-full
apt-get install nginx

相关内容