一门APP开发教程

标题: windows服务器Apache环境配置SSL 2.4- [打印本页]

作者: 陈家粉儿    时间: 2020-12-21 11:48
标题: windows服务器Apache环境配置SSL 2.4-
在apache的配置文件(httpd.conf)中,对以下两句话取消注释
注意:第一条加载ssl,第二条引入配置文件


在你的Apache目录中找到\conf\httpd.conf并打开,找到如下两行
# LoadModule ssl_module modules/mod_ssl.so
# Include conf/extra/httpd-ssl.conf
将这两行前面的注释符号 # 去掉。
  1. LoadModule ssl_module modules/mod_ssl.so (如果找不到请确认是否编译过 openssl 插件)
  2. Include conf/extra/httpd-ssl.conf
复制代码




配置httpd-ssl.conf文件
在你的Apache目录中找到\conf\extra\httpd-ssl.conf
在httpd-ssl.conf文件中最后面添加如下信息,其中域名地址根据自己的实际情况修改。

  1. Listen 443

  2. SSLPassPhraseDialog  builtin

  3. SSLSessionCache        "shmcb:/Apache24/logs/ssl_scache(512000)"
  4. SSLSessionCacheTimeout  300

  5. <VirtualHost _default_:443>

  6. DocumentRoot "E:\web\public"
  7. ServerName www.abc.com:443
  8. ServerAdmin admin@example.com

  9. SSLEngine on

  10. SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL

  11. SSLCertificateFile "C:\Apache24\cert\www\public.pem"

  12. SSLCertificateKeyFile "C:\Apache24\cert\www\214132021230522.key"

  13. SSLCertificateChainFile "C:\Apache24\cert\www\chain.pem"

  14. <FilesMatch "\.(cgi|shtml|phtml|php)$">
  15.     SSLOptions +StdEnvVars
  16. </FilesMatch>
  17. <Directory "/Apache24/cgi-bin">
  18.     SSLOptions +StdEnvVars
  19. </Directory>

  20. BrowserMatch ".*MSIE.*" \
  21.          nokeepalive ssl-unclean-shutdown \
  22.          downgrade-1.0 force-response-1.0

  23. #   Per-Server Logging:
  24. #   The home of a custom SSL log file. Use this when you want a
  25. #   compact non-error SSL logfile on a virtual host basis.
  26. CustomLog "/Apache24/logs/ssl_request.log" \
  27.           "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x "%r" %b"

  28. </VirtualHost>
复制代码




在网站根目录的.htaccess文件中配置跳转
配置http跳转https
  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>
复制代码



更详细教程参考:https://www.cnblogs.com/gyjerry/p/7090439.html






欢迎光临 一门APP开发教程 (https://bbs.yimenapp.com/) Powered by Discuz! X3.4