为微信小程序开发做准备,在Centos 6.8下利用letsencrypt.sh脚本为nginx 配置免费https证书

前端之家收集整理的这篇文章主要介绍了为微信小程序开发做准备,在Centos 6.8下利用letsencrypt.sh脚本为nginx 配置免费https证书前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。


原文链接: http://PHPecshop.blog.51cto.com/6296699/1891737


最近在做微信小程序商城开发的时候,阅读官方api文档发现要求https,

wx.request(OBJECT)

wx.request发起的是 HTTPS 请求。


于是开始了在Centos 6.8下利用letsencrypt.sh脚本为Nginx 配置免费https(Let's Encrypt SSL证书)的路程。


1、下载letsencrypt.sh

#wgethttps://raw.githubusercontent.com/xdtianyu/scripts/master/lets-encrypt/letsencrypt.conf
#wgethttps://raw.githubusercontent.com/xdtianyu/scripts/master/lets-encrypt/letsencrypt.sh


2、修改letsencrypt.conf文件的参数

#vimletsencrypt.conf

#onlymodifythevalues,keyfileswillbegeneratedautomaticly.
ACCOUNT_KEY="letsencrypt-account.key"
DOMAIN_KEY="mtian.net.key"
DOMAIN_DIR="/usr/local/Nginx/html"#网站的根目录
DOMAINS="DNS:mtian.net,DNS:www.mtian.net"#你的网站域名,多个域名用,号分隔
#ECC=TRUE
#LIGHTTPD=TRUE


3、执行文件生成https所需要的ssl证书文件

添加执行权限并执行
#chmod+xletsencrypt.sh
#./letsencrypt.shletsencrypt.conf

运行完成后会在当前目录生成如下文件
letsencrypt-account.keylets-encrypt-x3-cross-signed.pemmtian.csr
letsencrypt.confmtian.chained.crtmtian.net.key
letsencrypt.shmtian.crt


5、修改Nginx配置文件,加入https

#vim/usr/local/Nginx/conf/Nginx.conf



server{
listen443ssl;
server_namewww.mtian.net;

sslon;

ssl_certificate/usr/local/Nginx/conf/mtian.chained.crt;
ssl_certificate_key/usr/local/Nginx/conf/mtian.net.key;


location/{
roothtml;
indexindex.htmlindex.htm;
}
}


6、复制letsencrypt.sh生成的mtian.chained.crt和mtian.net.key 件到 Nginx.conf中指定的目录/usr/local/Nginx/conf/

#cpmtian.chained.crt/usr/local/Nginx/conf/
#cpmtian.net.key/usr/local/Nginx/conf/


7、重启Nginx

#serviceNginxrestart

StoppingNginx:[OK]
StartingNginx:[OK]


8、打开浏览器访问https://www.mtian.net/,火狐和谷歌都可以正常访问并且有绿色的锁,https配置完成。

wKiom1h4ctrj-bJuAABfw68lusE728.png

wKioL1h4ctvgPFVHAAAyO7_tDxg730.png


微信小程序商城http://www.mtian.net/weixinapp.html

Laravel商城http://www.mtian.net/

原文链接:https://www.f2er.com/centos/379041.html

猜你在找的CentOS相关文章