服務器我是買的阿里雲的,域名也是在阿里雲上買的,注意一點,如今域名必須備案才能用,因此建議先買域名着手備案,等備好案再買服務器。php
粘個阿里雲推廣的鏈接,點進去有新人紅包
https://promotion.aliyun.com/ntms/yunparter/invite.html?userCode=ppef3go2html
若是是我的開發使用,服務器不用買太貴的,1M網速2G內存的就夠用了。
域名若是不是商用,也不用太好,我就用的.top,cn和com基本沒多少好聽的域名了。並且還很貴。nginx
https://freessl.cn/
申請Let's Encrypt的ssl證書web
好比咱們如今要給example.top申請證書安全
配置完成,檢測一下
進入檢測界面。檢測界面這樣,可是數據不全,先不用點,還要用剛纔那個界面的數據。點擊驗證
,經過以後會發給你一個壓縮包,裏邊就是證書啦。scp private.key root@112.125.88.123:/root/
,而後要求輸入密碼,文件就過去了。把兩個文件都傳過去。/usr/local/nginx/cert/
下了。server { listen 443; ssl on; ssl_certificate /usr/local/nginx/cert/full_chain.pem; ssl_certificate_key /usr/local/nginx/cert/private.key; keepalive_timeout 70; server_name example.top; root /data/webroot/example; charset utf-8; ssl_session_timeout 5m; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; fastcgi_param HTTPS on; fastcgi_param HTTP_SCHEME https; location / { index index.php index.html index.htm; if (-e $request_filename) { break; } if (!-e $request_filename) { rewrite ^/(.*)$ /index.php/$1 last; break; } } location ~ .+\.php($|/) { fastcgi_split_path_info ^(.+\.php)(/.+)$; # fastcgi_pass 127.0.0.1:9000; fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } access_log logs/calendar.yimeidan.access.log; error_log logs/calendar.yimeidan.error.log; } server { listen 80; server_name calendar.yimeidan.top; return 301 https://$server_name$request_uri; }
最後的最後,很關鍵,打開端口!!!打開端口!!!打開端口!!!
阿里雲的443端口默認是不打開的,須要以下操做打開端口。(80端口也是須要這麼打開的。)
點開你的阿里雲控制檯,找到你要用的服務器,而後點更多->網絡和安全組->安全組配置。
點配置規則,添加安全組規則。添加內容如圖。你也能夠這樣配好80端口。
服務器
理論上完活啦,有問題能夠留言交流。
成品截圖:
網絡
寫文不易,若是以爲幫到您了,能夠支持下。d=====( ̄▽ ̄*)b。
阿里雲新人紅包:https://promotion.aliyun.com/ntms/yunparter/invite.html?userCode=ppef3go2
阿里雲產品開年活動:https://www.aliyun.com/acts/product-section-2019/new-users?userCode=ppef3go2
阿里雲商標註冊服務:https://tm.aliyun.com/?userCode=ppef3go2session