卸载 Softaculous 后 Apache 无法启动或重新启动

卸载 Softaculous 后 Apache 无法启动或重新启动

我想重新启动我的服务器,所以我这样做了:

sudo service apache2 restart

它反而向我显示了下面的消息:

Job for apache2.service failed. See 'systemctl status apache2.service' and 'journalctl -xn' for details.

然后我照做了systemctl -l status apache2.service,结果如下:

    apache2.service - LSB: Apache2 web server
   Loaded: loaded (/etc/init.d/apache2)
  Drop-In: /lib/systemd/system/apache2.service.d
           └─forking.conf
   Active: failed (Result: exit-code) since Thu 2016-12-15 07:44:48 CST; 43min ago
  Process: 31239 ExecStart=/etc/init.d/apache2 start (code=exited, status=1/FAILURE)

Dec 15 07:44:48 s87890 apache2[31239]: Starting web server: apache2 failed!
Dec 15 07:44:48 s87890 apache2[31239]: The apache2 configtest failed. ... (warning).
Dec 15 07:44:48 s87890 apache2[31239]: Output of config test was:
Dec 15 07:44:48 s87890 apache2[31239]: apache2: Syntax error on line 216 of /etc/apache2/apache2.conf: Could not open configuration file /etc/apache2/conf-enabled/softaculous.conf: No such file or directory
Dec 15 07:44:48 s87890 apache2[31239]: Action 'configtest' failed.
Dec 15 07:44:48 s87890 apache2[31239]: The Apache error log may have more information.
Dec 15 07:44:48 s87890 systemd[1]: apache2.service: control process exited, code=exited status=1
Dec 15 07:44:48 s87890 systemd[1]: Failed to start LSB: Apache2 web server.
Dec 15 07:44:48 s87890 systemd[1]: Unit apache2.service entered failed state.

我查看了 /etc/apache2/apache2.conf 的第 216 行,看到的内容如下:

IncludeOptional conf-enabled/*.conf

我照做了journalctl -xn,结果显示:

    - Logs begin at Tue 2016-12-13 16:17:11 CST, end at Thu 2016-12-15 08:11:24 CST. --
Dec 15 08:11:05 s87890 sshd[32074]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=116.31.116.48  user=root
Dec 15 08:11:07 s87890 sshd[32074]: Failed password for root from 116.31.116.48 port 61622 ssh2
Dec 15 08:11:10 s87890 sshd[32074]: Failed password for root from 116.31.116.48 port 61622 ssh2
Dec 15 08:11:12 s87890 sshd[32074]: Failed password for root from 116.31.116.48 port 61622 ssh2
Dec 15 08:11:12 s87890 sshd[32074]: Received disconnect from 116.31.116.48: 11:  [preauth]
Dec 15 08:11:12 s87890 sshd[32074]: PAM 2 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=116.31.116.48  user=root
Dec 15 08:11:22 s87890 postfix/smtpd[32032]: warning: hostname dedic858.hidehost.net does not resolve to address 91.200.13.20: Name or service not kn
Dec 15 08:11:22 s87890 postfix/smtpd[32032]: connect from unknown[91.200.13.20]
Dec 15 08:11:24 s87890 sudo[32065]: ejandra : TTY=pts/0 ; PWD=/home/ejandra ; USER=root ; COMMAND=/bin/journalctl -xn
Dec 15 08:11:24 s87890 sudo[32065]: pam_unix(sudo:session): session opened for user root by ejandra(uid=0)

我已经卸载了 Apache,然后再次安装,但仍然出现相同的错误。这里可能出了什么问题?

答案1

仔细看看你的systemctl -l status apache2.service输出。问题不在于 /etc/apache2/apache2.conf。

Dec 15 07:44:48 s87890 apache2[31239]: apache2: Syntax error on line 216 of /etc/apache2/apache2.conf: Could not open configuration file /etc/apache2/conf-enabled/softaculous.conf: No such file or directory

apache 尝试包含配置文件/etc/apache2/conf-enabled/softaculous.conf

这可能是符号链接损坏。尝试禁用配置a2disconf softaculous或删除符号链接(如果有)

答案2

我是怎么想出来的:

实际上发生的事情是,我尝试按照他们的指示从 ISPConfig 卸载 Softaculous文档。此后,我无法执行以下操作:

sudo service apache2 restart

我接下来为应对错误所做的愚蠢的事情是卸载然后重新安装 apache2,按照类似问题的答案进行操作这里我没有先检查日志。但是,我仍然无法重新启动 Apache2。

所以我决定检查日志然后通过

sudo systemctl -l status apache2.service

然后它显示了无法打开的错误/etc/apache2/conf-enabled/softaculous.conf。然后我删除softaculous.conf/etc/apache2/conf-enabled

之后,不断出现有关依赖项的新错误。然后我意识到,当我安装 apache2 时,它是通过指南这里。这是在 Debian 8 中安装“完美服务器”的顺序指南,我认为单独卸载 apache2 会把一切都搞乱。

因此,我所做的就是再次按照上述指南中的过程进行操作,直到我重新安装了所有内容。但是,当我提示时,我遇到了另一个问题,sudo systemctl -l status apache2.service因为我无法执行此操作sudo service apache2 reload。它向我显示了以下错误:

apache2.service - LSB: Apache2 web server
   Loaded: loaded (/etc/init.d/apache2)
  Drop-In: /lib/systemd/system/apache2.service.d
           └─forking.conf
   Active: inactive (dead) since Fri 2016-12-16 04:53:27 CST; 12min ago
  Process: 9441 ExecStop=/etc/init.d/apache2 stop (code=exited, status=0/SUCCESS)
  Process: 9423 ExecStart=/etc/init.d/apache2 start (code=exited, status=0/SUCCESS)

Dec 16 04:53:27 s87890 apache2[9423]: (98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
Dec 16 04:53:27 s87890 apache2[9423]: (98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
Dec 16 04:53:27 s87890 apache2[9423]: no listening sockets available, shutting down
Dec 16 04:53:27 s87890 apache2[9423]: AH00015: Unable to open logs
Dec 16 04:53:27 s87890 apache2[9423]: Action 'start' failed.
Dec 16 04:53:27 s87890 apache2[9423]: The Apache error log may have more information.
Dec 16 04:53:27 s87890 apache2[9423]: .
Dec 16 04:53:27 s87890 apache2[9441]: Stopping web server: apache2.
Dec 16 04:53:27 s87890 systemd[1]: Started LSB: Apache2 web server.
Dec 16 04:53:37 s87890 systemd[1]: Unit apache2.service cannot be reloaded because it is inactive.

然后我发现 Apache2 无法启动,因为 nginx 已安装并使用端口 80。我通过执行以下操作将其卸载:

sudo apt-get remove nginx nginx-common
sudo apt-get autoremove

之后,我能够成功重新启动并重新加载 Apache2。

所以我在这里学到的教训是,不要在没有先确认日志的情况下盲目地遵循其他答案。

感谢所有帮助我的人,特别是如何检查日志(因为我对 Apache 不是很熟悉)。

相关内容