在 ubuntu 中启动 apache2 服务器时出错

Posted

技术标签:

【中文标题】在 ubuntu 中启动 apache2 服务器时出错【英文标题】:Error while starting apache2 server in ubuntu 【发布时间】:2020-09-20 10:13:24 【问题描述】:

systemctl 启动 apache2.service

收到此错误:-

apache2.service 的作业失败,因为控制进程以错误代码退出。 详见“systemctl status apache2.service”和“journalctl -xe”。

systemctl status apache2.service的日志

● apache2.service - The Apache HTTP Server
   Loaded: loaded (/lib/systemd/system/apache2.service; disabled; vendor preset: enabled)
  Drop-In: /lib/systemd/system/apache2.service.d
           └─apache2-systemd.conf
   Active: failed (Result: exit-code) since Tue 2020-06-02 08:24:55 IST; 49s ago
  Process: 9759 ExecStart=/usr/sbin/apachectl start (code=exited, status=127)

Jun 02 08:24:55 GS-4996 systemd[1]: Starting The Apache HTTP Server...
Jun 02 08:24:55 GS-4996 apachectl[9759]: /usr/sbin/apachectl: 174: /usr/sbin/apachectl: /usr/sbin/apache2: not found
Jun 02 08:24:55 GS-4996 apachectl[9759]: Action 'start' failed.
Jun 02 08:24:55 GS-4996 apachectl[9759]: The Apache error log may have more information.
Jun 02 08:24:55 GS-4996 systemd[1]: apache2.service: Control process exited, code=exited status=127
Jun 02 08:24:55 GS-4996 systemd[1]: apache2.service: Failed with result 'exit-code'.
Jun 02 08:24:55 GS-4996 systemd[1]: Failed to start The Apache HTTP Server.

【问题讨论】:

sn-p 不包含整个输出。共享整个输出以及共享httpd -t 命令输出。 @Pandurang 我正在使用 ubuntu,这里只有 apache2。你能告诉我如何在ubuntu中执行httpd -t吗? 请分享以下两条命令输出:ll /usr/sbin/apache2 ll /etc/init.d/apache2 对于第一个命令:ll /usr/sbin/apache2 输出是:ls: cannot access '/usr/sbin/apache2': No such file or directory 对于第二个命令:ll /etc/init. d/apache2 输出为:-rwxr-xr-x 1 root root 8181 Jul 16 2019 /etc/init.d/apache2* 使用/etc/init.d/apache2 start启动Apache 【参考方案1】:

能否附上错误日志或“systemctl status apache2.service”的输出

【讨论】:

我已附上错误日志。请帮我解决这个问题。【参考方案2】:

看起来 apache2 文件在服务器上不可用。 /usr/sbin/apache2 由 apache2-bin 提供。 apache2-bin 是 apache2 包的一个依赖,所以没有它 apache2 将无法正常工作。打开终端并输入:

sudo apt install --reinstall apache2-bin   
sudo service apache2 start  

【讨论】:

非常感谢,现在我的 apache 服务器开始运行了,能否分享在 ubuntu 上安装和配置 apache2 服务器的整个步骤。就像我不知道 apache2-bin 安装一样。这可能对我很有帮助。 我投了赞成票,但我是一个新的贡献者,声誉非常低,所以得到这个:感谢您的反馈!声望低于 15 人的投票将被记录,但不会更改公开显示的帖子得分。虽然我接受了。再次感谢。 您能否分享一下在 ubuntu 上从头开始安装和配置 apache2 的验证/正确步骤。 你可以在ubuntu网站上查看。【参考方案3】:

我的最佳解决方案无需重新启动.. 经过很长时间的 se :)

sudo apt-get --reinstall install apache2-bin

【讨论】:

【参考方案4】:

第 1 步:停止 nginx 并启动 apache

就是这样。

service nginx stop
systemctl restart postgresql
systemctl restart apache2
systemctl status apache2.service

【讨论】:

以上是关于在 ubuntu 中启动 apache2 服务器时出错的主要内容,如果未能解决你的问题,请参考以下文章

Ubuntu 14.04 服务器:phpMyAdmin 的 Apache2 问题

无法在 WSL Ubuntu 20.04.3 LTS(焦点)中使用本地主机上的 Ansible 模块服务启动 Apache2

Ubuntu14.04配置文件Apache2.conf

debian Linux下 apache2 出错,不能启动,求助各位大侠

ubuntu下如何设置apache的启动和重启

Ubuntu16.0.4下安装卸载apache2服务