我正在将我的网络服务器从我的 Windows 笔记本电脑迁移到另一台运行 Ubuntu 18.04 服务器的计算机上。我正在使用的程序是Abyss Web Server(虽然它似乎不是程序的问题,但它似乎更可能与Ubuntu有关)。
如果它在不同的端口(如端口 8000、8080 等)上,我可以很好地运行此 Web 服务器,但是当我尝试使用端口 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
找到的每一个可能的命令- 仍然没有显示。到底是怎么回事??????
小于 1024 的 TCP 和 UDP 端口只能由
root
进程使用(打开)。通常,Web 服务器以 uid=0 开始,开始侦听端口(例如)80,然后切换到非特权用户(例如www-data
的情况下apache2
)。您的Abyss Web Server可能会或可能不会这样做,但无论如何,如果您想使用小于 1024 的端口,则必须从
root
用户启动它。有关“知名端口”的更多信息,请参阅:https ://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers#Well-known_ports