• Windows 下配置 Apache 支持 https


    1、打开cmd ,输入  F:  // 切换到Apache安装路径,我的Apache安装目录在 F盘

    2、cd F:Apachein

    3、set "openssl_conf = F:Apacheconfopenssl.cnf"

      临时设置openssl_conf路径,也可在环境变量中建新项目,键为 OPENSSL_CONF,值为 F:Apacheconfopenssl.cnf (看自己的安装路径),不然在生成key时会报“WARNING: can't open config file: c:/openssl-1.0.2j-win64/ssl/openssl.cnf”错误。

    4、openssl genrsa -out server.key 1024  // 生成私密key

    5、copy server.key server.key.org  // 复制server.key 防止启动Apache要密码

    6、openssl rsa -in server.key.org -out server.key

    7、openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt  // 生成证书,会要求填写国家、省份、城市、域名、邮箱等信息

    8、配置Apahce  !!!  核心步骤 !!!

    8.1 在http.conf文件中去掉下面代码前的#号

    #LoadModule socache_shmcb_module modules/mod_socache_shmcb.so #LoadModule ssl_module modules/mod_ssl.so #Include conf/extra/httpd-ssl.conf
    8.2 修改 F:/Apache/conf/extra/httpd-ssl.conf 文件

    <VirtualHost _default_:443> DocumentRoot "F:/Apache/htdocs/ushark.net" ServerName www.ushark.net:443 SSLCertificateFile "F:/Apache/bin/server.crt" SSLCertificateKeyFile "F:/Apache/bin/server.key" </VirtualHost>

    9、配置http自动跳转到https,在 httpd-vhosts.conf 文件中编辑如下内容,也可参考这篇文章:https://wiki.apache.org/httpd/RedirectSSL

    <VirtualHost *:80>
      DocumentRoot "F:/Apache/htdocs/ushark.net"
      ServerName www.ushark.net
      Redirect / https://www.ushark.net/  # !!! 核心代码 !!!
    </VirtualHost>

    10、httpd -k restart  // 重新启动Apache,报错的话就查找相应原因解决

  • 相关阅读:
    自己用的vim插件
    关于利用python进行验证码识别的一些想法
    看看黑客如何破解验证码机制
    不懂技术的人不要对懂技术的人说这很容易实现
    4个mysql客户端工具的比较
    GB2312,GBK和UTF-8的区别
    Windows下用Python你会几种copy文件的方法?
    python3.4连接mysql数据库的方法
    python3操作mysql教程
    python win32com
  • 原文地址:https://www.cnblogs.com/gentsir/p/8358544.html
Copyright © 2020-2023  润新知