Apache2 无法在 Ubuntu 上重新启动

Apache2 无法在 Ubuntu 上重新启动

我已经在 ubuntu 中安装了 apache 2,但是当我尝试重新启动时,出现了这个错误

vmware@ubuntu:~$ sudo /etc/init.d/apache2 restart
 * Restarting web server apache2                                                apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
[Mon Apr 12 17:37:43 2010] [warn] NameVirtualHost *:80 has no VirtualHosts
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
[Mon Apr 12 17:37:43 2010] [warn] NameVirtualHost *:80 has no VirtualHosts

当我尝试http://localhost

现在我收到这个错误

sudo /etc/init.d/apache2 restart
sudo: unable to resolve host ubuntu
 * Restarting web server apache2                                                apache2: apr_sockaddr_info_get() failed for ubuntu
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
apache2: apr_sockaddr_info_get() failed for ubuntu
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
(98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open log

s

沒有任何进展

This is the netstat output


Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 localhost:postgresql    *:*                     LISTEN      -               
tcp        0      0 *:3389                  *:*                     LISTEN      -               
tcp        0      0 localhost:3350          *:*                     LISTEN      -               
tcp        0      0 *:ssh                   *:*                     LISTEN      -               
tcp        0      0 localhost:ipp           *:*                     LISTEN      -               
tcp6       0      0 localhost:postgresql    [::]:*                  LISTEN      -               
tcp6       0      0 [::]:microsoft-ds       [::]:*                  LISTEN      -               
tcp6       0      0 [::]:netbios-ssn        [::]:*                  LISTEN      -               
tcp6       0      0 [::]:5900               [::]:*                  LISTEN      1338/vino-server

重新启动 apache 后

sudo /etc/init.d/apache2 restart
sudo: unable to resolve host ubuntu
 * Restarting web server apache2                                                apache2: apr_sockaddr_info_get() failed for ubuntu
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
 ... waiting .apache2: apr_sockaddr_info_get() failed for ubuntu
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

答案1

即使您的配置中有一个 NameVirtualHost 声明,但您似乎缺少 VirtualHost 部分。

您要么需要删除 NameVirtualHost 行,要么修复您的虚拟主机配置。

编辑:关于您的最新更新 - 这意味着端口 80 上正在运行其他程序,因此 Apache 无法侦听该端口上的连接。您可能正在运行其他守护程序(或者可能是恶意 Apache 进程)。

您可以运行netstat --tcp --listening --programs以显示所有监听套接字以及监听每个端口的应用程序。您将在“本地地址”列中查找*:www*:80。一旦您知道监听端口 80 的应用程序,您就可以确定解决问题的最佳方法。

答案2

apache2:无法可靠地确定服务器的完全限定域名,使用 127.0.0.1 作为 ServerName

/etc/hostname如果您不需要在单台机器上提供多个网站服务,请编辑或使用 ServerName 指令来修复该错误。

要解决其余错误,请查看/etc/apache2/sites-enabled您的配置。应该有一个默认站点仅提供/var/www

答案3

请点击此处:设置基于名称的虚拟主机

要找出还有什么占用了端口 80,请运行以下命令:

netstat -lnp | grep :80

然后您可以执行类似的操作killall -9 [process-name]并尝试重新启动。

相关内容