首先注册一个腾讯云账号获取域名,https://www.qcloud.com/
这里已经获取了一个证书, 只是写一个

选择申请证书


上面我已经申请好了证书, 申请证书之后是验证, 建议使用域名解析认证,在服务器里面放文件的验证方式比较难实现,验证之后点击下载

下面开始去服务器配置https证书,

下载的文件一般有Apache和Nginx以及IIS,有的会有Tomcat,这里我们取用Nginx,

这里的证书我从腾讯云搬到阿里云都是centos系统, 现在采用了win系统的
首先进入Nginx配置文件夹,我的这个只是相对的,根据不同的环境改变

然后在同级目录下面新建一个ssl的文件(也可以取自己喜欢的),然后把证书拖进去,接着开始配置Nginx, 打开Nginx
vim nginx.conf
添加如下配置

server {
listen 443;
server_name image.wertp.cn; #填写绑定证书的域名 11
ssl on;
ssl_certificate /usr/local/nginx/conf/ssl/1_image.wertp.cn_bundle.crt;
ssl_certificate_key /usr/local/nginx/conf/ssl/2_image.wertp.cn.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #按照这个协议配置
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;#按照这个套件配置
ssl_prefer_server_ciphers on;
location / {
root /data/wwwroot/image.wertp.cn/public;
index index.php index.html index.htm;
if (!-e $request_filename){
rewrite ^/(.*)$ /index.php?s=$1 last;
}
#(thinkphp rewrite路由重写模式添加这段,否则是普通模式)
}
location ~ .php$ {
root /data/wwwroot/image.wertp.cn/public;
fastcgi_pass unix:/dev/shm/php-cgi.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
fastcgi_param HTTPS on;
include fastcgi.conf;
}
#(兼容php添加这段)
}
接下来保存,退出,然后重启Nginx,建议先reload一下, 有时候会因为路径的问题导致Nginx无法重启,或者重启后不生效
service nginx reload
service nginx restart
如果提示重启成功,就可以去配置域名了,然后配置好的结果就是这样的

这个是为了小程序特意加入的不同类型图片,因为之前的尺度太大,无法通过审核.这个网站原来是用的centos7.3的系统, 现在测试放到了win上面.
配置基本就这么多了, 熟悉了还是比较简单的,之前踩坑比较多, 各种的证书bug, 现在觉得这个还不错
作者:rosekissyou
链接:https://www.jianshu.com/p/da25bfa571d4
來源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。