微信打不开https网址,是因为https部署存在问题。
该怎么部署呢?
0
前置条件
web OK http服务 OK 网站能正常访问,申请证书成功 443端口已经开启
1
下载证书
腾讯云配置 www.yixzm.cn 域名为例,证书下载在这里:
https://console.cloud.tencent.com/ssl
下载后,Apache文件夹内容:
1_root_bundle.crt 证书文件 2_www.yixzm.cn.crt 证书文件 3_www.yixzm.cn.key 私钥文件
2
安装证书
编辑 /etc/httpd/conf.d 目录下的 ssl.conf 配置文件。修改如下内容:
DocumentRoot "/var/www/html"
#填写证书名称
ServerName cloud.tencent.com
#启用 SSL 功能
SSLEngine on
#证书文件的路径
SSLCertificateFile /etc/httpd/ssl/2_www.yixzm.cn.crt
#私钥文件的路径
SSLCertificateKeyFile /etc/httpd/ssl/3_www.yixzm.cn.key
#证书链文件的路径
SSLCertificateChainFile /etc/httpd/ssl/1_root_bundle.crt
修改后重启 apache 服务
systemctl restart httpd
如果没有 ssl.conf 文件,则
yum install mod_ssl
安装即可
3
默认使用https协议
在 httpd.conf 配置文件中添加如下内容:
# 新增
RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)?$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
至此,OK啦!
注意:
apache 要开重写
LoadModule rewrite_module modules/mod_rewrite.so