代码之家  ›  专栏  ›  技术社区  ›  abalter

Apache无法启动,因为“根目录的密码失败…”

  •  1
  • abalter  · 技术社区  · 7 年前

    我在尝试启动apache时出现以下错误:

    balter@balterbox:/etc/apache2$ sudo service apache2 restart
    Job for apache2.service failed because the control process exited with error code.
    See "systemctl  status apache2.service" and "journalctl  -xe" for details.
    

    以下是日志:

    balter@balterbox:/etc/apache2$ sudo systemctl status apache2.service
    ● apache2.service - The Apache HTTP Server
       Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
      Drop-In: /lib/systemd/system/apache2.service.d
               └─apache2-systemd.conf
       Active: failed (Result: exit-code) since Fri 2018-02-16 14:45:58 PST; 33s ago
      Process: 2534 ExecStart=/usr/sbin/apachectl start (code=exited, status=1/FAILURE)
          CPU: 34ms
    

    balter@balterbox:~$ sudo journalctl -xe | tail
    Feb 16 15:05:17 balterbox sshd[2777]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=###.###.###.###  user=root
    Feb 16 15:05:19 balterbox sshd[2777]: Failed password for root from ###.###.###.### port 33812 ssh2
    Feb 16 15:05:19 balterbox sshd[2779]: Connection closed by 114.32.120.181 port 47696 [preauth]
    Feb 16 15:05:21 balterbox sshd[2777]: Failed password for root from ###.###.###.### port 33812 ssh2
    Feb 16 15:05:24 balterbox sshd[2777]: Failed password for root from ###.###.###.### port 33812 ssh2
    Feb 16 15:05:24 balterbox sshd[2777]: Received disconnect from ###.###.###.### port 33812:11:  [preauth]
    Feb 16 15:05:24 balterbox sshd[2777]: Disconnected from authenticating user root 121.18.238.39 port 33812 [preauth]
    Feb 16 15:05:24 balterbox sshd[2777]: PAM 2 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=###.###.###.###  user=root
    Feb 16 15:05:29 balterbox sudo[2781]:   balter : TTY=pts/2 ; PWD=/home/balter ; USER=root ; COMMAND=/bin/journalctl -xe
    Feb 16 15:05:29 balterbox sudo[2781]: pam_unix(sudo:session): session opened for user root by balter(uid=0)
    

    编辑: @Carlo建议的结果:

    balter@balterbox:~$ sudo apache2ctl restart
    AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
    httpd not running, trying to start
    (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 'restart' failed.
    The Apache error log may have more information.
    balter@balterbox:~$ sudo apachectl restart
    AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
    httpd not running, trying to start
    (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 'restart' failed.
    The Apache error log may have more information.
    balter@balterbox:~$ sudo /etc/init.d/apache2 restart
    [....] Restarting apache2 (via systemctl): apache2.serviceJob for apache2.service failed because the control process exited with error code.
    See "systemctl  status apache2.service" and "journalctl  -xe" for details.
    

    为什么无法打开日志?

    4 回复  |  直到 7 年前
        1
  •  1
  •   CFV    7 年前
    • 在配置文件中设置服务器名。
    • 使用Kill命令终止apache进程(因为您的日志显示该地址已经在使用中)。
    • 使用启动apache sudo apache2ctl start .
        2
  •  0
  •   CFV    7 年前

    重新启动服务器并发布Apache状态。

    尝试

    • sudo apache2ctl restart

    • sudo apachectl restart

    • sudo /etc/init.d/apache2 restart

    • 在这些命令之后发布apache日志

    • 另请参见: Restart apache - Ask Ubuntu

        3
  •  0
  •   CFV    7 年前

    尝试此命令 sudo killall -9 httpd 并启动apache sudo service httpd start . 这篇文章是关于您的问题: Apache will not restart 如果不起作用,请重新安装apache。

        4
  •  0
  •   Community CDub    4 年前

    来自 Digital Ocean :

    在这种情况下,您可以忽略“根用户密码失败”错误-它们针对的是SSH服务器,而不是web服务器。出于这个原因,您需要从journalctl命令中删除tail,并在文件中上下翻页,以查找有关Apache的特定行。

    的输出 apache2ctl restart 但是,您添加的内容显示了问题所在—端口80上已经有东西在侦听,因此Apache无法开始侦听该端口号上的连接。您可以运行如下命令 sudo netstat -tnlp 获取正在侦听连接的正在运行进程的列表,并查找其本地地址以:80结尾的进程。停止相应的服务,然后再次尝试启动Apache。

    事实证明,我还运行了Nginx(我安装它是为了做一些实验)。转向Nginx,并能够启动Apache。

    此外,特别要感谢卡洛·费德里科·维斯科沃坚持这一点。