阿里云CentOS7.3下,为Apache配置SSL证书

因为小程序访问的接口地址必须是https协议的,所以这里找了一下教程,对自己阿里云CentOS7.3的Apache服务器进行了一个证书的配置。这里用的是阿里云免费提供的证书。

下面是详细步骤:(不过有个坑,现在还没解决,我需要手动输入https,不然默认进来的时还是http协议,这里还需要再研究一下怎么从http强行跳转至https

1、登录阿里云,购买免费证书

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

2、下载证书,将证书导入服务器上

在这里插入图片描述
1)远程连接你的服务器,安装SSL模块

yum install mod_ssl -y

2)建一个目录,存放刚才下载的证书

mkdir /etc/httpd/ssl/

4)修改Apache的配置文件

vim /etc/httpd/conf/httpd.conf

修改如下

#LoadModule ssl_module modules/mod_ssl.so   
#删除行首的配置语句注释符号“#”加载mod_ssl.so模块启用SSL服务,Apache默认是不启用该模块的。如果找不到该配置,请重新编译mod_ssl模块。
#Include conf/extra/httpd-ssl.conf   删除行首的配置语句注释符号“#”。

5)保存退出,然后编辑ssl配置文件

vim /etc/httpd/conf.d/ssl.conf

6)修改如下几行

SSLProtocol all -SSLv2 -SSLv3    
# 添加SSL协议支持协议,去掉不安全的协议。
SSLCipherSuite HIGH:!RC4:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!EXP:+MEDIUM    
# 使用此加密套件。

DocumentRoot "/var/www/html"  #网页文件路径

ServerName www.hrbustcheny.info:443  #改为自己的域名,  这里切记是 域名:443

SSLEngine on  #启用SSL功能

SSLCertificateFile   /etc/httpd/ssl/2_www.**.cn.crt   #填写证书文件路径

SSLCertificateKeyFile   /etc/httpd/ssl/3_www.***.cn.key  #填写私钥文件路径

SSLCertificateChainFile   /etc/httpd/ssl/1_root_bundle.crt  #填写证书链文件路径

7)重启Apache服务器

systemctl restart httpd.service

完成!

看一下效果
浏览器输入 www.hrbustcheny.info/myblog
在这里插入图片描述
手动输入:https://www.hrbustcheny.info/myblog/
在这里插入图片描述
默认还是跳转到http协议上,但是现在https协议已经好用了。
剩下的就是研究一下怎么让http强行跳转到https上面了,等有时间再研究。
bingo~

参考链接:
https://yq.aliyun.com/articles/637307?spm=a2c4e.11153940.blogcont641517.16.5a9c33a39y88Hy#comment

https://yq.aliyun.com/articles/641517

https://help.aliyun.com/document_detail/98727.html?spm=a2c4g.11186623.2.27.30a42de9zw4vPN#concept-zsp-d1x-yfb

https://www.cnblogs.com/guoxhblog/p/7686245.html

猜你喜欢

转载自blog.csdn.net/Cheny_Yang/article/details/88974986
今日推荐