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