Windows下的Apache对于https服务的配置

服务器   发布日期:2023年05月13日   浏览次数:628

1.下载证书,一般为四个文件

注意:服务器不一样,证书的数量可能不一样

  1. 214132021230522.key
  2. 214132021230522.pem
  3. chain.pem
  4. public.pem12345

2.在apache的配置文件(httpd.conf)中,对以下两句话取消注释

注意:第一条加载ssl,第二条引入配置文件

  1. LoadModule ssl_module modules/mod_ssl.so (如果找不到请确认是否编译过 openssl 插件)
  2. Include conf/extra/httpd-ssl.conf

3.配置conf/extra/httpd-ssl.conf文件,加入主机信息和证书路径

注意: 路径配置错误可能打不开服务器

  1. Listen 443
  2.  
  3. SSLPassPhraseDialog builtin
  4.  
  5. SSLSessionCache "shmcb:/Apache24/logs/ssl_scache(512000)"
  6. SSLSessionCacheTimeout 300
  7.  
  8. <VirtualHost _default_:443>
  9.  
  10. DocumentRoot "E:\web\public"
  11. ServerName www.abc.com:443
  12. ServerAdmin admin@example.com
  13.  
  14. SSLEngine on
  15.  
  16. SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
  17.  
  18. SSLCertificateFile "C:\Apache24\cert\www\public.pem"
  19.  
  20. SSLCertificateKeyFile "C:\Apache24\cert\www\214132021230522.key"
  21.  
  22. SSLCertificateChainFile "C:\Apache24\cert\www\chain.pem"
  23.  
  24. <FilesMatch "\.(cgi|shtml|phtml|php)$">
  25. SSLOptions +StdEnvVars
  26. </FilesMatch>
  27. <Directory "/Apache24/cgi-bin">
  28. SSLOptions +StdEnvVars
  29. </Directory>
  30.  
  31. BrowserMatch ".*MSIE.*" \
  32. nokeepalive ssl-unclean-shutdown \
  33. downgrade-1.0 force-response-1.0
  34.  
  35. # Per-Server Logging:
  36. # The home of a custom SSL log file. Use this when you want a
  37. # compact non-error SSL logfile on a virtual host basis.
  38. CustomLog "/Apache24/logs/ssl_request.log" \
  39. "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
  40.  
  41. </VirtualHost>

4.在网站根目录的.htaccess文件中配置跳转

  1. <IfModule mod_rewrite.c>
  2. RewriteEngine on
  3. RewriteBase /
  4. RewriteCond %{SERVER_PORT} !^443$
  5. RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
  6. </IfModule>

5.重启 Apache。


以上就是Windows下的Apache对于https服务的配置的详细内容,更多关于Windows下的Apache对于https服务的配置的资料请关注九品源码其它相关文章!