使用腾讯云可以很方便的申请HTTPS证书. 只需要一些简单的步骤就可以开启全站HTTPS
开启全站https: nginx部分
从腾讯云下载申请的证书, 解压后上传到服务器
scp ~/Downloads/superbear.me/Nginx/* root@superbear.me:/etc/nginx/
编辑vim /etc/nginx/nginx.conf
, 在http
中加入
server {
listen 80;
listen [::]:80;
server_name superbear.me;
rewrite ^(.*)$ https://$host$1 permanent;
}
server {
listen 443 ssl http2 default_server spdy fastopen=3;
listen [::]:443 ssl http2 default_server spdy fastopen=3;
server_name superbear.me;
keepalive_timeout 70;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
root /srv/wordpress;
index index.html index.htm index.php;
client_max_body_size 10m;
ssl_certificate "/etc/nginx/1_superbear.me_bundle.crt";
ssl_certificate_key "/etc/nginx/2_superbear.me.key";
ssl_session_cache shared:SSL:2m;
ssl_session_timeout 20m;
location / {
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
try_files $uri =404;
include fastcgi.conf;
fastcgi_pass 127.0.0.1:9000;
}
}
参考: CentOS 7 + nginx 配置 wordpress
Centos 6/7 升级 PHP 5.6 到 7.1/7.2
开启全站https: wrodpress部分
将设置>常规
中的WordPress地址和
站点地址`改成https的
--查看wordpress的数据库在哪
SHOW DATABASES;
USE wordpress;
--查看posts表是什么
SHOW TABLES;
--查询图片路径对应的数据
SELECT post_content FROM wp_posts WHERE post_content LIKE '%/wp-content/uploads%';
--将路径替换成https
UPDATE wp_posts SET post_content = replace(post_content, 'http://superbear.me','https://superbear.me');
UPDATE wp_posts SET guid = REPLACE(guid, 'http://superbear.me','https://superbear.me');
最后进入外观>自定义>站点身份
, 将网站图标全部更换一遍. 刷新一下小锁就加在域名左边啦.
参考: 为图片开启https