Apache 2无法绑定,已经在使用的地址

我在Ubuntu 12.10上安装了Apache 2。 当我尝试使用sudo /etc/init.d/apache2 start服务sudo /etc/init.d/apache2 start ,我收到以下消息。

 *Starting web server apache2 (98)Address already in use: make_sock: could not bind to address 127.0.0.1:80 no listening sockets available, shutting down Unable to open logs Action 'start' failed. The Apache error log may have more information. [fail] 

很可能你已经在(或“绑定”)端口运行了某些东西。 尝试使用此命令查看有问题的进程:

 sudo lsof -i :80 

这列出了在端口80上侦听的进程。一旦找到了罪魁祸首,就会知道killkill -9哪个进程kill -9 (也是超级用户)。

请记住,假设您之前已经开始,Apache实例可能已经“陈旧”或变成了僵尸。 在后一种情况下,在某些情况下甚至可能需要重启。

否则请从dedunumax回答。

尝试sudo service apache2 start

然后键入

 sudo service apache2 status 

第二个命令将显示它是否正在运行。

我收到此错误消息,具有以下配置:

 # cat /etc/hosts 127.0.0.1 localhost 127.0.0.1 foo ... # cat /etc/apache2/sites-enabled/foo  ... # cat /etc/apache2/ports.conf ... NameVirtualHost *:80 Listen localhost:80 ... 

ports.conf更改为以下内容解决了以下问题:

 NameVirtualHost *:80 Listen 127.0.0.1:80 

我将此作为带有以下配置的apache错误消息:

 # cat /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 

我注释掉了:: 1条目并发出了apache restart命令。

 # cat /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 #::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 # sudo service httpd restart