Ubuntu上的nginx不会在启动时启动



Apache没有安装,只有nginx。

启动Ubuntu 22.04:

$ service nginx status
× 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 Wed 2022-07-20 13:09:24 EDT; 11s ago
Docs: man:nginx(8)
Process: 972 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 1010 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE)
CPU: 42ms
Jul 20 13:09:21 gojira nginx[1010]: nginx: [warn] duplicate MIME type "text/html" in /etc/nginx/sites-enabled/scalacourses.com:24
Jul 20 13:09:21 gojira nginx[1010]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Unknown error)
Jul 20 13:09:22 gojira nginx[1010]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Unknown error)
Jul 20 13:09:22 gojira nginx[1010]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Unknown error)
Jul 20 13:09:23 gojira nginx[1010]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Unknown error)
Jul 20 13:09:23 gojira nginx[1010]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Unknown error)
Jul 20 13:09:24 gojira nginx[1010]: nginx: [emerg] still could not bind()
Jul 20 13:09:24 gojira systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
Jul 20 13:09:24 gojira systemd[1]: nginx.service: Failed with result 'exit-code'.
Jul 20 13:09:24 gojira systemd[1]: Failed to start A high performance web server and a reverse proxy server.
$ sudo systemctl start nginx
Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xeu nginx.service" for details.
$ sudo systemctl disable nginx
Synchronizing state of nginx.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install disable nginx
Removed /etc/systemd/system/multi-user.target.wants/nginx.service.
$ sudo systemctl enable nginx
Synchronizing state of nginx.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable nginx
Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /lib/systemd/system/nginx.service.
$ sudo systemctl start nginx
Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xeu nginx.service" for details.
$ sudo systemctl stop nginx
$ sudo systemctl start nginx
$ service nginx status
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2022-07-20 13:12:24 EDT; 11s ago
Docs: man:nginx(8)
Process: 6517 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 6518 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 6519 (nginx)
Tasks: 9 (limit: 38369)
Memory: 8.6M
CPU: 37ms
CGroup: /system.slice/nginx.service
├─6519 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;"
├─6520 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
├─6521 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
├─6522 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
├─6523 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
├─6524 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
├─6525 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
├─6526 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
└─6527 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
Jul 20 13:12:24 gojira systemd[1]: Starting A high performance web server and a reverse proxy server...
Jul 20 13:12:24 gojira nginx[6517]: nginx: [warn] duplicate MIME type "text/html" in /etc/nginx/sites-enabled/scalacourses.com:24
Jul 20 13:12:24 gojira nginx[6518]: nginx: [warn] duplicate MIME type "text/html" in /etc/nginx/sites-enabled/scalacourses.com:24
Jul 20 13:12:24 gojira systemd[1]: Started A high performance web server and a reverse proxy server.
$ grep -r listen /etc/nginx/*
/etc/nginx/nginx.conf:#     listen     localhost:110;
/etc/nginx/nginx.conf:#     listen     localhost:143;
/etc/nginx/sites-available/scalacourses.com:  listen 80;
/etc/nginx/sites-available/scalacourses.com:  listen [::]:80 ipv6only=on;
/etc/nginx/sites-available/scalacourses.com:  listen 443 ssl;
/etc/nginx/sites-available/scalacourses.com:  listen [::]:443 ipv6only=on ssl;
/etc/nginx/sites-available/default: listen 80 default_server;
/etc/nginx/sites-available/default: listen [::]:80 default_server;
/etc/nginx/sites-available/default: # listen 443 ssl default_server;
/etc/nginx/sites-available/default: # listen [::]:443 ssl default_server;
/etc/nginx/sites-available/default:#    listen 80;
/etc/nginx/sites-available/default:#    listen [::]:80;
/etc/nginx/sites-enabled/scalacourses.com:  listen 80;
/etc/nginx/sites-enabled/scalacourses.com:  listen [::]:80 ipv6only=on;
/etc/nginx/sites-enabled/scalacourses.com:  listen 443 ssl;
/etc/nginx/sites-enabled/scalacourses.com:  listen [::]:443 ipv6only=on ssl;

是什么原因导致了这种行为?

我发现另一个服务pound在nginx之前启动并占用了443端口。我不再需要pound,所以我删除了导致它启动的链接:

$ sudo rm /etc/rc2.d/S04pound

相关内容

  • 没有找到相关文章

最新更新