[英]Adding SSL to Apache Server
我们今天获得了SSL证书,我正在尝试将SSL证书添加到域中,以便我们可以通过https访问该网站,但是我遇到了问题。
我们有一个在Windows上运行的apache服务器。
该配置对于端口80完美运行,但是当我将端口443添加到配置中时,一切都停止工作。
我启动Apache时遇到的错误是
The requested operation has failed.
我添加了以下行
Listen 443
在下面的行:
Listen 80
我添加了以下VirtualHost配置
<VirtualHost _default_:443>
DocumentRoot "c:/path/to/website"
ServerName example.com
ServerAlias example.com www.example.com
SSLEngine on
SSLCertificateFile "c:/path/to/cert/cert.crt"
SSLCertificateKeyFile "c:/path/to/cert/key.key"
SSLCACertificateFile "c:/path/to/cert/bundle.ca-bundle"
</VirtualHost>
但是,每当我添加完后启动apache服务器时,它就不会启动,并且会出现错误。
我已经注释掉了部分代码,并将问题缩小到了Listen 443
行。 添加此内容时,我是否没有考虑?
这些是error.log中的最后3行
[Thu Jun 08 18:15:31.909142 2017] [mpm_winnt:notice] [pid 66428:tid 712] AH00422: Parent: Received shutdown signal -- Shutting down the server.
[Thu Jun 08 18:15:47.209776 2017] [mpm_winnt:notice] [pid 67332:tid 620] AH00364: Child: All worker threads have exited.
[Thu Jun 08 18:15:48.067933 2017] [mpm_winnt:notice] [pid 66428:tid 712] AH00430: Parent: Child process exited successfully.
编辑
这是运行httpd.exe -e debug
的响应
(OS 10013)An attempt was made to access a socket in a way forbidden by its access permissions. : AH00072: make_sock: could not bind to address [::]:443
(OS 10013)An attempt was made to access a socket in a way forbidden by its access permissions. : AH00072: make_sock: could not bind to address 0.0.0.0:443
AH00451: no listening sockets available, shutting down
AH00015: Unable to open logs
我不知道您的httpd.conf文件是什么样子,也许您意外删除/更改了某些值。
您需要做的第一件事是还原您的httpd.conf文件并在没有SSL配置的情况下启动服务。 一旦工作,您可以继续执行以下步骤:
在一个单独的所有SSL设置的新文件中,一个名为httpd-ssl.conf的新文件也许是个好名字。
之后,在主httpd.conf的末尾添加以下行以包括新文件:
# Secure (SSL/TLS) connections
Include conf/httpd-ssl.conf
这是避免在主配置中意外更改/删除某些内容并限制可能错误源的一种好习惯,您将知道任何错误都将与所包含的新文件有关。
您的新conf / httpd-ssl.conf应该看起来像这样(标准设置):
# HTTPS port
Listen 443
<VirtualHost _default_:443>
# General setup for the virtual host
DocumentRoot "C:/your_httpd_path/htdocs"
ServerName www.example.com:443
ServerAdmin admin@example.com
ErrorLog "C:/your_httpd_path/logs/error.log"
TransferLog "C:/your_httpd_path/logs/access.log"
# SSL Engine Switch:
SSLEngine on
# Server Certificates:
SSLCertificateFile "c:/path/to/cert/cert.crt"
SSLCertificateKeyFile "c:/path/to/cert/key.key"
SSLCACertificateFile "c:/path/to/cert/bundle.ca-bundle"
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory "C:/your_httpd_path/cgi-bin">
SSLOptions +StdEnvVars
</Directory>
CustomLog "C:/your_httpd_path/logs/ssl_request.log" \
"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
</VirtualHost>
您是否尝试过使用httpd.exe -e调试? 也许我们可以在这种模式下找到有用的东西。
更新:啊哈! 你有一个错误! 它可能是与443某处重复的行。
您可以在notepad ++中检查文件并搜索与“ 443”匹配的所有符合项吗? 可能您已经配置了443,并尝试再次添加它? 您只需要一行即可:
Listen 443
或者也许已经在该端口中运行? 检查:
netstat -na | findstr "443"
如果您有类似的东西:
TCP [::]:443 [::]:0 LISTENING
然后,您的443端口上正在运行其他操作。 无论如何,您可以更改您的httpd conf并设置其他任何端口(例如4443 ie),或者杀死现在占用443的进程。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.