nginx下如何配置 ssl证书?腾讯云ssl证书为例!php
目前为止,https已经成为一种趋势,想要开启https就须要ssl证书。html
首先,为域名注册ssl证书。nginx
腾讯云注册地址:https://cloud.tencent.com/product/ssl?from=qcloudHpHeaderSslshell
(腾讯云这里有免费的我的证书,一次性一年)服务器
接下来怎么配置到nginx呢?session
假设咱们的网站域名是adcc.me,php环境采用的是phpstudy一键安装的。测试
/phpstudy/server/nginx/conf/vhosts 目录下的 adcc.me.conf 文件配置以下:网站
server { listen 443; server_name adcc.me; root "/phpstudy/www/adcc.me"; ssl on; ssl_certificate /phpstudy/server/nginx/conf/1_adcc.me_bundle.crt; #ssl证书存放路径 ssl_certificate_key /phpstudy/server/nginx/conf/2_adcc.me.key; #ssl证书存放路径 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 / { index index.html index.htm index.php; #autoindex on; } location ~ \.php(.*)$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_split_path_info ^((?U).+\.php)(/?.+)$; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root; include fastcgi_params; } }
(注意ssl证书上传的路径)spa
修改好adcc.me.conf文件以后。经过xshell5 登陆服务器,输入phpstudy restart 命令,重启nginx便可。rest
接下来在/phpstudy/www/adcc.me 路径下放一个index.html的网页,使用https://adcc.me测试访问下,若是能访问就说明ssl证书已经配置成功。
关于phpstudy 的使用说明,请参照:http://www.cnblogs.com/hylsay/p/7782738.html
原文参考:https://adcc.me