Board logo

标题: [教程] Apache下配置网站SSL实现https访问(虚拟主机) [打印本页]

作者: 向上的葱子    时间: 2017-5-7 22:39     标题: Apache下配置网站SSL实现https访问(虚拟主机)

以前的文章我们讲到如何在nginx下如何配置https,具体教程可以看这里:http://www.aitiancheng.com/article-246.html

为网站配置https,首先需要SSL证书,具体怎么申请SSL证书请看我以前的教程:http://www.aitiancheng.com/article-333.html


检查apache是否安装了 mod_ssl.so模块。

检查方法是查看是否在 modules (/www/wdlinux/apache/modules/)下存在。不存在那么安装(yum -y install mod_ssl)。



1、编辑Apache根目录下 conf/httpd.conf 文件
找到 #LoadModule ssl_module modules/mod_ssl.so 和 #Include conf/extra/httpd-ssl.conf,去掉前面的#号注释;

2、编辑Apache根目录下 conf/extra/httpd-ssl.conf 文件
修改如下内容:

将<VirtualHost default:443>***</VirtualHost>删除。

3、上传SSL证书
将申请好的SSL证书上传到www/wdlinux/apache/conf/ssl目录下。

注意:apache下的SSL证书是3个文件。

4、启用网站的https访问
在apache/vhost目录下找到网站的配置文件。一般是XXX.conf

使用notepad++打开配置文件,将配置文件中的内容复制一下到配置文件里面,然后将复制的内容中的80修改为443;

在复制的内容中添加以下内容:

SSLEngine on
    SSLCertificateFile /www/wdlinux/apache/conf/ssl/2_www.domain.com_cert.crt
    SSLCertificateKeyFile /www/wdlinux/apache/conf/ssl/3_www.domain.com.key
    SSLCertificateChainFile /www/wdlinux/apache/conf/ssl/1_root_bundle.crt
以上代码的意思是:

第一句开启SSL,

后面三句是SSL证书路径。

5、重启apache
重启下apache,尝试用https访问网站试下呢。



6、将http跳转到https
具体教程看这里:http://www.aitiancheng.com/article-563.html


该教材原文地址:http://www.aitiancheng.com/article-558.html
作者: poohyxp    时间: 2017-7-5 16:14

感谢分享!!!




欢迎光临 WDlinux官方论坛 (http://www.wdlinux.cn/bbs/) Powered by Discuz! 7.2