Apache 2.4 重新加载失败

Apache 2.4 重新加载失败

我的 Apache 在进行一些更改后无法重新加载,在这种情况下,是通过 Webmin 添加新的 VHOST 后。这不是第一次发生这种情况,上次我解决了重新安装 Apache 的问题,但确实不是解决问题的令人满意的方法。

在 Webmin 中我收到此错误

Failed to start apache :
 :
Starting apache2 (via systemctl): apache2.service.

因此我尝试通过 ssh 手动重新加载 Apache

这就是发生的事情

root@myvps:/# /etc/init.d/apache2 reload
Reloading apache2 configuration (via systemctl): apache2.serviceJob for apache2.service failed. See 'systemctl status apache2.service' and 'journalctl -xn' for details. failed!

所以这是journalctl-xn回复

Jan 04 08:55:51 myvps systemd[1]: Reload failed for LSB: Apache2 web server.
-- Subject: Unit apache2.service has finished reloading its configuration
-- Defined-By: systemd
-- Support: lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit apache2.service has finished reloading its configuration
--
-- The result is failed.
Jan 04 08:56:01 myvps CRON[3403]: pam_unix(cron:session): session opened for user root by (uid=0)
Jan 04 08:56:01 myvps CRON[3404]: (root) CMD (cd / && run-parts --report /etc/cron.hourly)
Jan 04 08:56:01 myvps CRON[3403]: pam_unix(cron:session): session closed for user root
Jan 04 08:56:02 myvps systemd[1]: Reloading LSB: Apache2 web server.
-- Subject: Unit apache2.service has begun with reloading its configuration
-- Defined-By: systemd
-- Support: freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit apache2.service has begun with reloading its configuration
Jan 04 08:56:02 myvps systemd[1]: Failed to reset devices.list on /system.slice/apache2.service: No such file or directory
Jan 04 08:56:03 myvps apache2[3420]: Reloading web server: apache2 failed!
Jan 04 08:56:03 myvps apache2[3420]: Apache2 is not running ... (warning).
Jan 04 08:56:03 myvps systemd[1]: apache2.service: control process exited, code=exited status=1
Jan 04 08:56:03 myvps systemd[1]: Reload failed for LSB: Apache2 web server.
-- Subject: Unit apache2.service has finished reloading its configuration
-- Defined-By: systemd
--
-- Unit apache2.service has finished reloading its configuration
--
-- The result is failed.

这是systemctl 状态 apache2.service

Jan 04 09:23:43 myvps apache2[3819]: Action 'start' failed.
Jan 04 09:23:43 myvps apache2[3819]: The Apache error log may have more information.
Jan 04 09:23:43 myvps apache2[3819]: .
Jan 04 09:23:43 myvps systemd[1]: Started LSB: Apache2 web server.
-- Subject: Unit apache2.service has finished start-up
-- Defined-By: systemd
-- Support: lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit apache2.service has finished starting up.
--
-- The start-up result is done.
Jan 04 09:24:03 myvps systemd[1]: Reloading LSB: Apache2 web server.
-- Subject: Unit apache2.service has begun with reloading its configuration
-- Defined-By: systemd
--
-- Unit apache2.service has begun with reloading its configuration
Jan 04 09:24:03 myvps systemd[1]: Failed to reset devices.list on /system.slice/apache2.service: No such file or directory
Jan 04 09:24:03 myvps apache2[3868]: Reloading web server: apache2 failed!
Jan 04 09:24:03 myvps apache2[3868]: Apache2 is not running ... (warning).
Jan 04 09:24:03 myvps systemd[1]: apache2.service: control process exited, code=exited status=1
Jan 04 09:24:03 myvps systemd[1]: Reload failed for LSB: Apache2 web server.
-- Subject: Unit apache2.service has finished reloading its configuration
-- Defined-By: systemd
--
-- Unit apache2.service has finished reloading its configuration
--
-- The result is failed.

这些是 VPS 的特性

  • Debian Linux 8
  • Apache 2.4.10
  • Webmin 1.780
  • x86_64 上的内核和 CPU Linux 2.6.32-042stab108.8
  • BIND 9.9.5

Apache 错误日志中的一些其他详细信息:

[Mon Jan 04 05:16:05.615503 2016] [mpm_event:notice] [pid 367:tid 140186227066752] AH00489: Apache/2.4.10 (Debian) OpenSSL/1.0.1k configured -- resuming normal operations
[Mon Jan 04 05:16:05.615527 2016] [core:notice] [pid 367:tid 140186227066752] AH00094: Command line: '/usr/sbin/apache2'
[Mon Jan 04 06:22:05.208150 2016] [core:error] [pid 428:tid 140185949918976] [client clientIP:clientPort] AH00135: Invalid method in request quit
[Mon Jan 04 08:34:33.316012 2016] [mpm_event:notice] [pid 367:tid 140186227066752] AH00493: SIGUSR1 received.  Doing graceful restart
(98)Address already in use: AH00072: make_sock: could not bind to address vhostIp:vhostPort
[Mon Jan 04 08:34:33.343511 2016] [mpm_event:alert] [pid 367:tid 140186227066752] no listening sockets available, shutting down
[Mon Jan 04 08:34:33.343518 2016] [:emerg] [pid 367:tid 140186227066752] AH00019: Unable to open logs, exiting

我的 apache2.conf http://pastebin.com/xcedmPi0

我的 VirtualHost 配置文件 000-默认.conf http://pastebin.com/QYgMtTaK

webmin配置文件 pastebin.com/wFAe1uyS

有谁可以帮忙吗?

谢谢。

答案1

从错误日志来看,您要么错误配置了虚拟主机,要么Listen 80在 apache 配置文件中存在重复的条目。

(98)地址已在使用中:AH00072:make_sock:无法绑定到地址 vhostIp:vhostPort

在您的默认虚拟主机配置文件中,尝试更改<VirtualHost *><VirtualHost *:80>并重新启动 apache。对于基于名称的虚拟主机,您无需指定 IP 地址。

还要检查您的/etc/apache2/ports.conf文件中是否存在端口声明的重复条目。

来自OP的更新: 通过删除 ports.conf 中的一行<IfModule ssl_module> Listen 443 Listen vpsIp:5673(在 vhost 创建失败期间由 Webmin 添加的行)解决了问题

答案2

根据我的经验,Webmin 往往会生成错误的 Apache vHost 配置。配置文件会显示类似

虚拟主机 127.0.0.1:80

或您的 IP 地址。但是,您希望

虚拟主机 *:80

使用星号代替 IP。

这个问题在 Webmin 中已经存在一段时间了,我不知道他们为什么还没有修复它。最好手动编写配置,或者使用替代的 WebCP,比如 Ajenti。

相关内容