Apache 未运行,即使清除并重新安装后也是如此

Apache 未运行,即使清除并重新安装后也是如此

尝试启动 apache 后,我总是看到这一行:

Job for apache2.service failed because the control process exited with error code. See "systemctl status apache2.service" and "journalctl -xe" for details.
invoke-rc.d: initscript apache2, action "start" failed.

● apache2.service - LSB: Apache2 web server
● apache2.service - LSB: Apache2 web server
  Loaded: loaded (/etc/init.d/apache2; bad; 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:33:40 EST; 7ms ago
 Docs: man:systemd-sysv-generator(8)
 Process: 3196 ExecStart=/etc/init.d/apache2 start (code=exited, status=1/FAILURE)

Feb 16 14:33:40 JohnstonHost apache2[3196]:  *
Feb 16 14:33:40 JohnstonHost apache2[3196]:  * The apache2 configtest failed.
Feb 16 14:33:40 JohnstonHost apache2[3196]: Output of config test was:
Feb 16 14:33:40 JohnstonHost apache2[3196]: apache2: Syntax error on line 140 of /etc/apache2/apache2.conf: Syntax error on line 2 of /etc/apache2/mods-enabled/php7.0.load: Cannot load /usr/lib/apache2/modules/libphp7...file or directory
Feb 16 14:33:40 JohnstonHost apache2[3196]: Action 'configtest' failed.
Feb 16 14:33:40 JohnstonHost apache2[3196]: The Apache error log may have more information.
Feb 16 14:33:40 JohnstonHost systemd[1]: apache2.service: Control process exited, code=exited status=1
Feb 16 14:33:40 JohnstonHost systemd[1]: Failed to start LSB: Apache2 web server.
Feb 16 14:33:40 JohnstonHost systemd[1]: apache2.service: Unit entered failed state.

我已经尝试过清除、重新安装、清除并重新安装 apache2-bin、清除 php、清除 mysql、清除所有内容。我尝试过删除除 root 之外的所有用户及其目录,重新创建它们,然后重新安装 - 问题依然存在。我还尝试过安装和运行两个命令来修复 apache 无法运行的问题,但尝试连接时出现 500 错误。我使用的是 ubuntu 服务器,因此只能访问终端。

答案1

您的第 2 行有语法错误。它报告找不到/etc/apache2/mods-enabled/php7.0.loadlib/usr/lib/apache2/modules/libphp7

尝试使用以下命令禁用 php 或 php7,然后观察会发生什么。

sudo a2dismod php
sudo service apache2 start

从表面上看,您尚未安装所有必要的 php 包。或者 php 安装已损坏。通常,

sudo apt-get install php libapache2-mod-php 

答案2

我无意中删除了目录/etc/apache2/mods-enabled并重新安装了 apache2,从而解决了这个问题。我怀疑只需删除php7.0.conf然后php7.0.load重新安装 php 就可以解决问题。

相关内容