启用 SSL 后 Apache 不会重新启动

Ste*_*n66 5 ssl apache2

一旦我 a2enmod ssl 模块并重新启动 apache 我收到以下错误:

Restarting web server apache2
AH00548: NameVirtualHost has no effect and will be removed in the next 
release     /etc/apache2/ports.conf:14
(98)Address already in use: AH00072: make_sock: could not bind to address
[::]:443
(98)Address already in use: AH00072: make_sock: could not bind to address
0.0.0.0:443
no listening sockets available, shutting down
AH00015: Unable to open logs
Action 'start' failed.
The Apache error log may have more information.
Run Code Online (Sandbox Code Playgroud)

要停止它,我可以 disenmod 或注释掉 ports.conf 文件中的以下模块行:

Listen 80
#<IfModule mod_ssl.c>
#    Listen 443
#</IfModule>
<IfModule mod_gnutls.c>
    Listen 443
</IfModule>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Run Code Online (Sandbox Code Playgroud)

任何帮助将非常感激

Luk*_*kas 4

输出的以下几行表明其他程序已经在侦听端口 443,并且由于 Apache 不支持端口共享,因此它无法绑定到该端口,因此它会关闭。

(98)Address already in use: AH00072: make_sock: could not bind to address
(98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:443
Run Code Online (Sandbox Code Playgroud)

因此,我建议您关闭侦听该端口的程序。您可以使用以下命令确定哪些程序正在侦听 TCP 端口 443(必须以超级用户身份执行):

netstat -tlpn | grep 443
Run Code Online (Sandbox Code Playgroud)

然后关闭已经监听的程序(例如通过使用service <programme> stop或 通过使用kill <processID>(进程 ID 也由 提供netstat)。之后,您可以通过使用service apache2 start或通过执行启动 Apache /etc/init.d/apache2 start。当您使用 Ubuntu/Debian 时,这两个命令都有效。如果您正在使用 CentOS/RedHat Apache 名为httpd.

  • 如果它对某人有帮助,我的问题是我在两个地方有“Listen 443”。删除重复项就解决了。 (3认同)