Ubuntu 18.04 apache2 错误

Ubuntu 18.04 apache2 错误

我尝试了一下sudo systemctl restart apache2,得到了以下输出:apache2.service 的作业失败,因为控制进程以错误代码退出。有关详细信息,请参阅“systemctl status apache2.service”和“journalctl -xe”。

当我尝试“systemctl status apache2.service”时:

● apache2.service - Apache HTTP 服务器 已加载:已加载(/lib/systemd/system/apache2.service;已启用;供应商预设:已启用) 插入:/lib/systemd/system/apache2.service.d └─apache2-systemd.conf 活动:失败(结果:退出代码)自 2019-02-11 星期一 03:02:35 UTC;2 分 3 秒前 进程:12193 ExecStart=/usr/sbin/apachectl start(代码=exited,状态=1/FAILURE)

当我尝试:“journalctl -xe”时:

Hint: You are currently not seeing messages from other users and the system.
      Users in groups 'adm', 'systemd-journal' can see all messages.
      Pass -q to turn off this notice.
-- Support: http://www.ubuntu.com/support
-- 
-- Unit UNIT has finished starting up.
-- 
-- The start-up result is RESULT.
Feb 11 02:39:01 ths systemd[4215]: Reached target Default.
-- Subject: Unit UNIT has finished start-up
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- Unit UNIT has finished starting up.
-- 
-- The start-up result is RESULT.
Feb 11 02:39:01 ths systemd[4215]: Startup finished in 70ms.
-- Subject: User manager start-up is now complete
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- The user manager instance for user 1001 has been started. All services queued
-- for starting have been started. Note that other services might still be starting
-- up or be started at any later time.
-- 
-- Startup of the manager took 70596 microseconds.
lines 1794-1816/1816 (END)

我尝试了谷歌搜索的多种解决方案,也尝试重新安装 Apache,但仍然出现此错误。有什么建议吗?

编辑: sudo systemctl status apache2 给出:

> ● 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 Mon 2019-02-11 03:37:30 UTC; 1min 36s ago   Process:
> 21753 ExecStart=/usr/sbin/apachectl start (code=exited,
> status=1/FAILURE)
> 
> Feb 11 03:37:30 ths systemd[1]: Starting The Apache HTTP Server... Feb
> 11 03:37:30 ths apachectl[21753]: (98)Address already in use: AH00072:
> make_sock: could not bind to address [::]:80 Feb 11 03:37:30 ths
> apachectl[21753]: (98)Address already in use: AH00072: make_sock:
> could not bind to address 0.0.0.0:80 Feb 11 03:37:30 ths
> apachectl[21753]: no listening sockets available, shutting down Feb 11
> 03:37:30 ths apachectl[21753]: AH00015: Unable to open logs Feb 11
> 03:37:30 ths apachectl[21753]: Action 'start' failed. Feb 11 03:37:30
> ths apachectl[21753]: The Apache error log may have more information.
> Feb 11 03:37:30 ths systemd[1]: apache2.service: Control process
> exited, code=exited status=1 Feb 11 03:37:30 ths systemd[1]:
> apache2.service: Failed with result 'exit-code'. Feb 11 03:37:30 ths
> systemd[1]: Failed to start The Apache HTTP Server.

编辑 2:$ apachectl configtest

Syntax OK

答案1

在输出中sudo systemctl status apache2我们可以看到以下消息:

... 无法绑定到地址 [::]:80 ...

...无法绑定到地址 0.0.0.0:80...

我猜想端口 80 被另一个服务使用。使用下列命令之一来查找该服务:

sudo lsof -i -n -P | grep ':80'
sudo netstat -peanut | grep ':80'

然后停止(或禁用)该服务并重新启动(启用)Apache。如果 Apache 成功启用,那么您可以决定永久禁用其他服务或更改两个冲突服务之一(Apache 或另一个)上的端口 80。

参考:

相关内容