• centOS7 apache ssl证书安装配置


    背景说明:服务器是centOS7.4 七牛申请的免费ssl证书
    默认apache是没有安装SSL模块的,所以需要安装,接着使用命令:
    yum install -y mod_ssl

    apache目录 /usr/local/apache/
    vim conf/httpd.conf
    再 Listen 80下面添加一行
    Listen 443
    找到 #LoadModule ssl_module modules/mod_ssl.so 和 #Include conf/extra/httpd-ssl.conf,去掉前面的#号注释;

    先将要修改的文件备份是个好习惯。
    编辑Apache根目录下 conf/extra/httpd-ssl.conf 文件,修改如下内容:
    <VirtualHost 0.0.0.0:443>
        DocumentRoot "/data/www/default"
        ServerName ding.com
        ServerAlias www.ding.com
        <Directory /data/www/default>
                #AllowOverride伪静态
                AllowOverride All
                Require all granted
            </Directory>
        SSLEngine on
        SSLCertificateFile /usr/local/apache/conf/ssl/www.ding.com.cer
        SSLCertificateKeyFile /usr/local/apache/conf/ssl/www.ding.com.key
        SSLCertificateChainFile /usr/local/apache/conf/ssl/www.ding.com_ca.crt
    </VirtualHost>
    配置完成后,重新启动 Apache 就可以使用https://www.domain.com来访问了。

    若是腾讯云的免费ssl证书是,对应修改如下内容:
    SSLCertificateFile /usr/local/apache/conf/2_www.domain.com_cert.crt
    SSLCertificateKeyFile /usr/local/apache/conf/3_www.domain.com.key
    SSLCertificateChainFile /usr/local/apache/conf/1_root_bundle.crt

    如果要强制网站使用HTTPS,httpd-vhost.conf文件配置如下:
    <VirtualHost *:80>
    ServerName localhost
    ServerAlias localhost
    DocumentRoot /data/www/default
    <Directory /data/www/default>
        SetOutputFilter DEFLATE
        Options FollowSymLinks
        AllowOverride All
        Order Deny,Allow
        Require all granted
        DirectoryIndex index.php index.html index.htm
    </Directory>
    #强制http转向为https
    RewriteEngine on
    RewriteCond   %{HTTPS} !=on
    RewriteRule   ^(.*)  https://%{SERVER_NAME}$1 [L,R]
    </VirtualHost>

  • 相关阅读:
    SVN 使用教程
    MVC图片上传压缩
    MVC 上传下载压缩
    C# WinForm生成二维码,一维码,条形码 操作
    C#MVC生成二维码
    ajax post方式提交到.net core api
    .net core多文件上传 日志记录
    C# .net Core 文件上传
    C#.netmvc单文件上传 ajax上传文件
    详细的sql语句
  • 原文地址:https://www.cnblogs.com/idjl/p/9610561.html
Copyright © 2020-2023  润新知