wordpress HTTPS修正

前文:迁移wordpress到HTTPS

前文提到,使用docker部署,因为前后https模式不同步(前面是https后面是http://ip:port)导致需要修改配置文件,所以我决定把wordpress从docker迁移出来,因为docker挂载目录的其实就是wordpress本体在的位置


server {
  listen  443;
  server_name wpdev.endercaster.lan;#记得改掉
 #SSL证书配置参照前文
  root /opt/wordpress;#记得改掉
  location / {
      try_files $uri $uri/ /index.php?$is_args$args; #这里需要注意一下,不要少打
      index index.php;
  }
  # 这里替换为:在设置->固定连接->改为任意一个非朴素型
  #location ~ ^/wp-json/ {
  #    rewrite ^/wp-json/(.*?)$ /?rest_route=/$1 last;
  #}
  location ~ \.php$ {
        fastcgi_pass unix:/run/php/wp-test.sock;
        include fastcgi.conf;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  }
}

然后把前文中wp-config.php加的代码都删掉。

配置php-fpm,如果只有这一个项目,可以把上面的fastcgi_pass改掉,跳过这步


[wordpress]#从www改为wordpress
user = www-data
group = www-data
listen = /run/php/wp-test.sock
listen.mode = 0666


# 重启php-fpm
systemctl restart php7.2-fpm
#现在可以重新读取nginx配置文件了
nginx -t 
# 如果上面的输出是successful的话
systemctl reload nginx

然后登录查看工具->站点健康,看看有没有少一些依赖,给它装上。

至此,我的站点终于完美的迁移到https啦!

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注