为什么 init 监听 80 端口?

为什么 init 监听 80 端口?

我的 Debian Sid 安装已init监听:::80并且无法nginx启动。

root@server01:~# systemctl status nginx.service
* 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 Sat 2015-11-07 11:06:01 GMT; 16s ago
  Process: 9506 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE)
  Process: 9501 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)

Nov 07 11:05:59 server01 nginx[9506]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Nov 07 11:05:59 server01 nginx[9506]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Nov 07 11:06:00 server01 nginx[9506]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Nov 07 11:06:00 server01 nginx[9506]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Nov 07 11:06:01 server01 nginx[9506]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Nov 07 11:06:01 server01 nginx[9506]: nginx: [emerg] still could not bind()
Nov 07 11:06:01 server01 systemd[1]: nginx.service: Control process exited, code=exited status=1
Nov 07 11:06:01 server01 systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Nov 07 11:06:01 server01 systemd[1]: nginx.service: Unit entered failed state.
Nov 07 11:06:01 server01 systemd[1]: nginx.service: Failed with result 'exit-code'.

netstat输出

root@server01:~#netstat -tulpn
tcp        0      0 0.0.0.0:44443           0.0.0.0:*               LISTEN      2878/pulseaudio
tcp        0      0 0.0.0.0:4713            0.0.0.0:*               LISTEN      2878/pulseaudio
tcp        0      0 0.0.0.0:31021           0.0.0.0:*               LISTEN      10395/x2goclient
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      1170/rpcbind
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1015/sshd
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      16155/cupsd
tcp        0      0 0.0.0.0:23              0.0.0.0:*               LISTEN      939/inetd
tcp        0      0 127.0.0.1:5432          0.0.0.0:*               LISTEN      1212/postgres
tcp        0      0 0.0.0.0:31001           0.0.0.0:*               LISTEN      14223/x2goclient
tcp6       0      0 :::36157                :::*                    LISTEN      2878/pulseaudio
tcp6       0      0 :::4713                 :::*                    LISTEN      2878/pulseaudio
tcp6       0      0 :::111                  :::*                    LISTEN      1170/rpcbind
tcp6       0      0 :::80                   :::*                    LISTEN      1/init
tcp6       0      0 :::22                   :::*                    LISTEN      1015/sshd
tcp6       0      0 ::1:631                 :::*                    LISTEN      16155/cupsd
tcp6       0      0 ::1:5432                :::*                    LISTEN      1212/postgres

systemctl -all list-sockets

LISTEN                          UNIT                            ACTIVATES
/dev/rfkill                     systemd-rfkill.socket           systemd-rfkill.service
/run/acpid.socket               acpid.socket                    acpid.service
/run/dmeventd-client            dm-event.socket                 dm-event.service
/run/dmeventd-server            dm-event.socket                 dm-event.service
/run/lvm/lvmetad.socket         lvm2-lvmetad.socket             lvm2-lvmetad.service
/run/lvm/lvmpolld.socket        lvm2-lvmpolld.socket            lvm2-lvmpolld.service
/run/systemd/fsck.progress      systemd-fsckd.socket            systemd-fsckd.service
/run/systemd/initctl/fifo       systemd-initctl.socket          systemd-initctl.service
/run/systemd/journal/dev-log    systemd-journald-dev-log.socket systemd-journald.service
/run/systemd/journal/socket     systemd-journald.socket         systemd-journald.service
/run/systemd/journal/stdout     systemd-journald.socket         systemd-journald.service
/run/systemd/journal/syslog     syslog.socket                   rsyslog.service
/run/udev/control               systemd-udevd-control.socket    systemd-udevd.service
/var/run/acpi_fakekey           acpi-fakekey.socket             acpi-fakekey.service
/var/run/avahi-daemon/socket    avahi-daemon.socket             avahi-daemon.service
/var/run/cups/cups.sock         cups.socket                     cups.service
/var/run/dbus/system_bus_socket dbus.socket                     dbus.service
[::]:80                         pywwetha.socket                 pywwetha.service
audit 1                         systemd-journald-audit.socket   systemd-journald.service
kobject-uevent 1                systemd-udevd-kernel.socket     systemd-udevd.service

^[[0;1;39m20 sockets listed.

curl command

root@server01:~#
root@server01:~# curl localhost
curl: (56) Recv failure: Connection reset by peer
root@server01:~# curl 0.0.0.0:80
curl: (7) Failed to connect to 0.0.0.0 port 80: Connection refused
root@server01:~# curl 127.0.0.1:80
curl: (7) Failed to connect to 127.0.0.1 port 80: Connection refused
root@server01:~# curl :::80
curl: (7) Failed to connect to :: port 80: Connection refused
root@server01:~#

答案1

根据您的附加输出,pywwetha 似乎正在侦听端口 80。

停止它:

systemctl stop pywwetha.service

然后使用以下命令禁用它:

systemctl disable pywwetha.service

然后尝试启动 nginx。

相关内容