1、前期准备
2、申请SSL证书(以阿里云为例)
2.1 控制台 -> 域名 -> 域名列表 -> 管理(最右侧)

2.2 域名信息 -> 开启免费SSL证书

2.3 单域名免费证书
(1)可以填入自己要申请的域名前缀(示例:www.zhaoshuai.me),提交即可。

(2)返回上级列表,我们就能看到已经申请的证书,需要一个审核时间,一般很快的。

3、Nginx 添加配置
3.1 我的订单 -> 下载

3.2 依据教程进行配置即可(Nginx服务器配置帮助说明)。
下述简单概述本博客的配置样例,以Nginx为例:
概要说明:
- listen 监听端口
- server_name 监听域名
- access_log 、error_log 日志目录
- root 项目的目录路径
- fastcgi_pass 监听了php-fpm的9000端口
示例:nginx配置,/etc/nginx/conf.d/zhaoshuai.me.conf :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
<span style="font-family: arial, helvetica, sans-serif;">server { listen 80; server_name zhaoshuai.me; access_log /data0/www/logs/zhaoshuai.me.access_log; error_log /data0/www/logs/zhaoshuai.me.error_log; root /data0/www/htdocs/wordpress; location / { root /data0/www/htdocs/wordpress; index index.php index.html index.htm; if (!-e $request_filename){ rewrite ^/(.*) /index.php last; } } location ~ \.php$ { set $real_script_name $fastcgi_script_name; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$real_script_name; include fastcgi_params; } } server { listen 443; server_name zhaoshuai.me; ssl on; root /data0/www/htdocs/wordpress; index index.html index.htm index.php; ssl_certificate cert/1539297736883.pem; ssl_certificate_key cert/1539297736883.key; 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; location / { root /data0/www/htdocs/wordpress; index index.php index.html index.htm; if (!-e $request_filename){ rewrite ^/(.*) /index.php last; } } location ~ \.php$ { set $real_script_name $fastcgi_script_name; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$real_script_name; include fastcgi_params; } }</span> |
评论1