编辑#1:

编辑#1:

我正在将我的网络服务器从 Windows 笔记本电脑迁移到另一台运行 Ubuntu 18.04 服务器的计算机。我使用的程序是 Abyss Web Server(虽然这似乎不是程序的问题,但似乎更可能是与 Ubuntu 有关)。

如果该 Web 服务器位于不同的端口(如端口 8000、8080 等),我可以正常运行它,但是当我尝试使用端口 80 时,出现以下错误:

-- Default host on port 80 has a listening problem (Local URL http://127.0.0.1)

Console local URL: http://127.0.0.1:9999

因为它可以监听我指定的任何其他端口,所以这肯定是 Ubuntu 的问题。

之前,我注意到 Apache2 已自动启用并使用端口 80,因此我禁用了它的自动启动功能,然后禁用了该服务。然后我重新启动了计算机。

再次启动时,我遇到了完全相同的问题。我使用了命令sudo lsof,但根据命令,没有任何内容使用它(这显然只是一个片段,但正如您所见,80 上没有任何内容):

kswapd0     40                  root  txt   unknown                                        /proc/40/exe (readlink: Permission denied)
kswapd0     40                  root NOFD                                                  /proc/40/fd (opendir: Permission denied)
kworker/u   41                  root  cwd   unknown                                        /proc/41/cwd (readlink: Permission denied)
kworker/u   41                  root  rtd   unknown                                        /proc/41/root (readlink: Permission denied)
kworker/u   41                  root  txt   unknown                                        /proc/41/exe (readlink: Permission denied)
kworker/u   41                  root NOFD                                                  /proc/41/fd (opendir: Permission denied)
ecryptfs-   42                  root  cwd   unknown                                        /proc/42/cwd (readlink: Permission denied)
ecryptfs-   42                  root  rtd   unknown                                        /proc/42/root (readlink: Permission denied)
ecryptfs-   42                  root  txt   unknown                                        /proc/42/exe (readlink: Permission denied)
ecryptfs-   42                  root NOFD                                                  /proc/42/fd (opendir: Permission denied)
kthrotld    84                  root  cwd   unknown                                        /proc/84/cwd (readlink: Permission denied)
kthrotld    84                  root  rtd   unknown                                        /proc/84/root (readlink: Permission denied)
kthrotld    84                  root  txt   unknown                                        /proc/84/exe (readlink: Permission denied)
kthrotld    84                  root NOFD                                                  /proc/84/fd (opendir: Permission denied)
acpi_ther   85                  root  cwd   unknown                                        /proc/85/cwd (readlink: Permission denied)
acpi_ther   85                  root  rtd   unknown                                        /proc/85/root (readlink: Permission denied)
acpi_ther   85                  root  txt   unknown                                        /proc/85/exe (readlink: Permission denied)
acpi_ther   85                  root NOFD                                                  /proc/85/fd (opendir: Permission denied)
kworker/u   86                  root  cwd   unknown                                        /proc/86/cwd (readlink: Permission denied)
kworker/u   86                  root  rtd   unknown                                        /proc/86/root (readlink: Permission denied)
kworker/u   86                  root  txt   unknown                                        /proc/86/exe (readlink: Permission denied)
kworker/u   86                  root NOFD                                                  /proc/86/fd (opendir: Permission denied)
ipv6_addr   90                  root  cwd   unknown                                        /proc/90/cwd (readlink: Permission denied)
ipv6_addr   90                  root  rtd   unknown                                        /proc/90/root (readlink: Permission denied)
ipv6_addr   90                  root  txt   unknown                                        /proc/90/exe (readlink: Permission denied)
ipv6_addr   90                  root NOFD                                                  /proc/90/fd (opendir: Permission denied)
kstrp       99                  root  cwd   unknown                                        /proc/99/cwd (readlink: Permission denied)
kstrp       99                  root  rtd   unknown                                        /proc/99/root (readlink: Permission denied)
kstrp       99                  root  txt   unknown                                        /proc/99/exe (readlink: Permission denied)
kstrp       99                  root NOFD                                                  /proc/99/fd (opendir: Permission denied)
charger_m  116                  root  cwd   unknown                                        /proc/116/cwd (readlink: Permission denied)
charger_m  116                  root  rtd   unknown                                        /proc/116/root (readlink: Permission denied)
charger_m  116                  root  txt   unknown                                        /proc/116/exe (readlink: Permission denied)
charger_m  116                  root NOFD                                                  /proc/116/fd (opendir: Permission denied)
scsi_eh_0  176                  root  cwd   unknown                                        /proc/176/cwd (readlink: Permission denied)
scsi_eh_0  176                  root  rtd   unknown                                        /proc/176/root (readlink: Permission denied)

那么为什么我仍然收到监听错误?我也允许端口 80 通过ufw,那么我还需要做什么才能让它正常工作?

编辑#1:

我去过另一种解决方案在此站点上查看哪些内容使用了 80 端口。

目前,我只是在端口 8000 上运行服务器。

正如您在下面看到的,Abyss Web Server 正在使用端口 8000,但没有任何东西使用 80。发生了什么事???

user@pc:~$ sudo netstat -peanut | grep ":80"
[sudo] password for user:
tcp        0      0 0.0.0.0:8000            0.0.0.0:*               LISTEN      1000       31628      1947/abyssws-x64  
tcp6       0      0 :::8000                 :::*                    LISTEN      1000       31627      1947/abyssws-x64 

编辑#2

下面的评论建议我使用ss -ltp,但我仍然无法找到使用端口 80 的内容:

State  Recv-Q  Send-Q     Local Address:Port             Peer Address:Port
LISTEN 0       80             127.0.0.1:mysql                 0.0.0.0:*      users:(("mysqld",pid=1355,fd=22))
LISTEN 0       50               0.0.0.0:netbios-ssn           0.0.0.0:*      users:(("smbd",pid=2229,fd=34))
LISTEN 0       100              0.0.0.0:pop3                  0.0.0.0:*      users:(("dovecot",pid=2123,fd=24))
LISTEN 0       100              0.0.0.0:imap2                 0.0.0.0:*      users:(("dovecot",pid=2123,fd=38))
LISTEN 0       10          192.168.0.27:domain                0.0.0.0:*      users:(("named",pid=1243,fd=25))
LISTEN 0       10             127.0.0.1:domain                0.0.0.0:*      users:(("named",pid=1243,fd=22))
LISTEN 0       128        127.0.0.53%lo:domain                0.0.0.0:*      users:(("systemd-resolve",pid=817,fd=13))
LISTEN 0       128              0.0.0.0:ssh                   0.0.0.0:*      users:(("sshd",pid=2129,fd=3))
LISTEN 0       5              127.0.0.1:ipp                   0.0.0.0:*      users:(("cupsd",pid=913,fd=7))
LISTEN 0       128            127.0.0.1:postgresql            0.0.0.0:*      users:(("postgres",pid=1241,fd=8))
LISTEN 0       128            127.0.0.1:953                   0.0.0.0:*      users:(("named",pid=1243,fd=23))
LISTEN 0       50               0.0.0.0:microsoft-ds          0.0.0.0:*      users:(("smbd",pid=2229,fd=33))
LISTEN 0       100              0.0.0.0:imaps                 0.0.0.0:*      users:(("dovecot",pid=2123,fd=40))
LISTEN 0       100              0.0.0.0:pop3s                 0.0.0.0:*      users:(("dovecot",pid=2123,fd=26))
LISTEN 0       50                  [::]:netbios-ssn              [::]:*      users:(("smbd",pid=2229,fd=32))
LISTEN 0       100                 [::]:pop3                     [::]:*      users:(("dovecot",pid=2123,fd=25))
LISTEN 0       100                 [::]:imap2                    [::]:*      users:(("dovecot",pid=2123,fd=39))
LISTEN 0       10                  [::]:domain                   [::]:*      users:(("named",pid=1243,fd=21))
LISTEN 0       128                 [::]:ssh                      [::]:*      users:(("sshd",pid=2129,fd=4))
LISTEN 0       5                  [::1]:ipp                      [::]:*      users:(("cupsd",pid=913,fd=6))
LISTEN 0       128                [::1]:postgresql               [::]:*      users:(("postgres",pid=1241,fd=7))
LISTEN 0       128                [::1]:953                      [::]:*      users:(("named",pid=1243,fd=24))
LISTEN 0       50                  [::]:microsoft-ds             [::]:*      users:(("smbd",pid=2229,fd=31))
LISTEN 0       100                 [::]:imaps                    [::]:*      users:(("dovecot",pid=2123,fd=41))
LISTEN 0       100                 [::]:pop3s                    [::]:*      users:(("dovecot",pid=2123,fd=27))

这有点令人恼火。

我也尝试过sudo netstat -ltnp,并且找到了所有可能的命令这里- 仍然什么都没有显示。到底发生了什么事??????

答案1

小于 1024 的 TCP 和 UDP 端口只能由进程使用(打开)root。通常,Web 服务器以 uid=0 启动,开始监听端口(例如)80,然后切换到非特权用户(例如www-data的情况apache2)。

你的Abyss 网络服务器可能会也可能不会这样做,但无论如何,如果您想使用小于 1024 的端口,则必须从用户启动它root

有关“知名端口”的更多信息,请参阅:https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers#Well-known_ports

相关内容