zoukankan      html  css  js  c++  java
  • centos7配置Apache支持HTTPS

    Apache版本2.4 
    安装mod_ssl 

    yum install mod_ssl

    建立文件夹,存放sslkey

    mkdir /etc/httpd/ssl/

    建立凭证档

    openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/httpd/ssl/apache.key -out /etc/httpd/ssl/apache.crt
    
    ...........................................................+++
    ..............+++
    writing new private key to '/etc/httpd/ssl/apache.key'
    -----
    You are about to be asked to enter information that will be incorporated
    into your certificate request.
    What you are about to enter is what is called a Distinguished Name or a DN.
    There are quite a few fields but you can leave some blank
    For some fields there will be a default value,
    If you enter '.', the field will be left blank.
    -----
    Country Name (2 letter code) [XX]:CHN
    string is too long, it needs to be less than  2 bytes long
    Country Name (2 letter code) [XX]:CN
    State or Province Name (full name) []:HB
    Locality Name (eg, city) [Default City]:WH
    Organization Name (eg, company) [Default Company Ltd]:ZZ
    Organizational Unit Name (eg, section) []:ZZ
    Common Name (eg, your name or your server's hostname) []:WWW^H^[[3~^[[3~^[[3~^[[3~^[[3~^[[3~
    Email Address []:webmaster@xxx.com

    需要填写一些内容,我随便填的…

    apache配置 
    /etc/httpd/conf.d/ssl.conf 
    我把这下面的内容复制到另外一个文件中配置的

    <VirtualHost _default_:443>
    *****
    </VirtualHost>

    需要修改的几项

    DocumentRoot "/var/www/example.com/public_html"
    
    ServerName www.example.com:443
    
    SSLCertificateFile /etc/httpd/ssl/apache.crt
    SSLCertificateKeyFile /etc/httpd/ssl/apache.key

    重启apache

    systemctl restart httpd.service

    通过以上步骤就能打开网页的https链接了,但是此时的https浏览器会提示不安全的链接,那么就需要到阿里云去申请一个CA证书,目前有免费版的CA证书,下面的链接是我发在百度的申请证书的教程,大家可以参考一下

    https://jingyan.baidu.com/album/4b07be3c92836148b380f318.html

    上一个效果图

     

    https变成绿色,说明证书生效!

  • 相关阅读:
    349元我们应该有什么样的期待原道N12豪华版 RK2906入手初体验
    漫谈国内智能手机市场现状
    将AltiumDesigner(Protel升级版)的PCB设计打造成利器——订制应用、操作、过滤表达式及其他一些微操作
    modelsim se 10.1a 下载与破解
    shell配置,选择,环境变量修改(ORACLE_HOME,ORACLE_SID),无法使用sqlplus
    /ibm/fan
    TrackPoint_configure_ThinkPad_squeeze(0616.2011)
    来个狠的
    JDBC for MSSql2005 简单示例
    oracle使用指南
  • 原文地址:https://www.cnblogs.com/liuboswu/p/7228622.html
Copyright © 2011-2022 走看看