我对 Ubuntu 了解甚少,当我尝试启动阿帕奇2服务器(如下所示)
root@ns3016274:/etc/apache2/sites-available# sudo service apache2 start
* Starting web server apache2 (98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
(98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
AH00015: Unable to open logs
Action 'start' failed.
The Apache error log may have more information.
*
* The apache2 instance did not start within 20 seconds. Please read the log files to discover problems
我确实重新安装了 apache2,但仍然遇到同样的问题。
答案1
答案就在消息中:(98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
。当apache2
尝试使用bind
系统调用开始监听端口 80 时,它失败了,因为其他某个进程已经成功调用了它bind
。
还有哪个过程?man lsof
导致:
sudo lsof -i TCP:80
由于我没有提供 80 端口,因此我们来看一下sshd
我的系统上的 22 端口():
$ sudo lsof -i TCP:22
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
sshd 1686 root 3u IPv4 13939 0t0 TCP *:ssh (LISTEN)
sshd 1686 root 4u IPv6 13941 0t0 TCP *:ssh (LISTEN)