尝试重新启动 Apache 时出现“无法打开日志”错误

use*_*920 6 networking apache2 log

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

root@server11362:~# sudo /etc/init.d/apache2 restart

Restarting web server apache2 (98)Address already in use: 
   make_sock: could not bind to address 111.90.150.93:80
no listening sockets available, shutting down
Unable to open logs
Action 'start' failed.
The Apache error log may have more information. 
Run Code Online (Sandbox Code Playgroud)

事实上,apache 日志不包含更多信息。

netstat -tulpn 返回以下内容

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      1098/mysqld     
tcp        0      0 127.0.0.1:6379          0.0.0.0:*               LISTEN      1414/redis-server
tcp        0      0 111.90.150.93:53        0.0.0.0:*               LISTEN      1068/named      
tcp        0      0 111.90.150.92:53        0.0.0.0:*               LISTEN      1068/named      
tcp        0      0 127.0.0.1:53            0.0.0.0:*               LISTEN      1068/named      
tcp        0      0 127.0.0.1:5432          0.0.0.0:*               LISTEN      1194/postgres   
tcp        0      0 0.0.0.0:44888           0.0.0.0:*               LISTEN      845/sshd        
tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN      1395/master     
tcp        0      0 127.0.0.1:953           0.0.0.0:*               LISTEN      1068/named      
tcp        0      0 0.0.0.0:6081            0.0.0.0:*               LISTEN      1435/varnishd   
tcp        0      0 127.0.0.1:6082          0.0.0.0:*               LISTEN      1434/varnishd   
tcp6       0      0 :::53                   :::*                    LISTEN      1068/named      
tcp6       0      0 :::44888                :::*                    LISTEN      845/sshd        
tcp6       0      0 :::25                   :::*                    LISTEN      1395/master     
tcp6       0      0 ::1:953                 :::*                    LISTEN      1068/named      
tcp6       0      0 :::6081                 :::*                    LISTEN      1435/varnishd   
udp        0      0 111.90.150.93:53        0.0.0.0:*                           1068/named      
udp        0      0 111.90.150.92:53        0.0.0.0:*                           1068/named      
udp        0      0 127.0.0.1:53            0.0.0.0:*                           1068/named      
udp6       0      0 :::53
Run Code Online (Sandbox Code Playgroud)

80端口没有任何东西,但我仍然无法重新启动

小智 8

可能有更多的破碎,因为你也得到

Unable to open logs
Run Code Online (Sandbox Code Playgroud)

首先,启用更多日志记录

LogLevel debug
Run Code Online (Sandbox Code Playgroud)

在您的/etc/apache2/apache2.conf.

检查您的文件权限/var/log/apache2

我经常使用以下命令进行调试:

strace -f apache2ctl start 2>&1|grep -v " ENOENT " | grep -Ee " E[A-Z]+"
Run Code Online (Sandbox Code Playgroud)

它准确地显示了哪些调用失败了。

[编辑]

另一个原因可能会产生重叠的收听地址,例如:

Listen *:80
Listen 1.2.3.4:80
Run Code Online (Sandbox Code Playgroud)

所以你监听所有接口,第二条监听线路试图打开一个已经打开的端口。就像这里描述的那样。

  • 尊重您的其他帖子,您应该首先检查“Listen”关键字的配置。 (2认同)