这里写自定义目录标题
前言
最近想把完美韵脚搞个小程序版,微信小程序需要https形式的访问,简单的了解后进行了对项目进行项目进行了https配置,期间也遇到几个坑,这里记录下。
我的项目配置:Apache24+Django1.9.2+Python3.5
申请https证书
https证书有免费版、收费版,也可以自己用工具生成,我出卖了个人信息,注册了腾讯云,拿到了一个免费使用一年的https证书。
腾讯云证书下载地址:https://cloud.tencent.com/document/product/400/6814
申请证书我选择了 文件验证 ,但是腾讯云文档上说的文件验证我操作没法访问,这里我通过Django设置views的urls来访问验证文件来解决的,添加的url如下。
url(r'^.well-known/pki-validation/fileauth.txt$', TemplateView.as_view(template_name=".well-known/pki-validation/fileauth.txt", content_type="text/plain"), name="test"),
验证后下载证书,下载证书如下:
配置https
放证书文件
我将证书文件放置到Apache24安装目录。
1. 配置httpd.conf
打开Apache24/conf/httpd.conf,进行配置修改,建议修改前先备份。
1.1 将配置文件中下面两行取消注释,开启ssl。
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
LoadModule ssl_module modules/mod_ssl.so
1.2 将配置文件中下面一行取消注释,注意 httpd-ahssl.conf 不要取消注释
Include conf/extra/httpd-ssl.conf
# Include conf/extra/httpd-ahssl.conf
2. 配置httpd-ssl.conf
打开Apache24/conf/extra/httpd-ssl.conf,进行配置修改,同样建议修改前先备份。
2.1 监听443端口
Listen 443
443端口是https的默认端口,这里确认它是443就好。
2.2 配置ServerName
将 ServerName及ServerAdmin由
ServerName www.example.com:443
<