[英]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.