ls -la 先扫一遍权限。常见失误是打包时把文件属主带成了旧服务器的 UID/GID,到了新环境成了无人认领的孤儿。一眼望去,如果看到大量 www-data 以外的属主,立刻 chown -R www-data:www-data /var/www/html,再 find . -type f -exec chmod 644 {} \; 和 find . -type d -exec chmod 755 {} \;。这两行命令相当于给服务器发了一张新的门禁卡,旧卡自然刷不开门。index.php,服务器找不到默认入口,就会按配置顺序往下找,找不到便礼貌返回 403。curl -I https://yourdomain/ 看响应头,如果 Content-Type 缺失且大小为 0,九成是缺入口。补传后记得清一次 OPCache:php -r 'opcache_reset();',别让小缓存继续把“空房间”塞给用户。location / 块里有没有 try_files $uri $uri/ /index.php?$args;,Apache 用户则检查 .htaccess 是否被新环境的 AllowOverride None 屏蔽。把规则补完,再 nginx -t && systemctl reload nginx,让配置热加载而非粗暴重启,减少毫秒级抖动。ufw status 看本地防火墙是否误伤自己。若启用了 Fail2ban,也查一下 jail.local 里有没有把自家 IP 段拉黑。四连检查后,再跑一次 curl -L https://yourdomain/ 观察返回码,如果仍是 403,继续第五轮。wp_options 表里的 home 和 siteurl 仍指向旧域名。一旦新域名未完全匹配,WordPress 会在 canonical 阶段把流量 301 回老地址,而老地址可能已 403。wp search-replace 'https://old.com' 'https://new.com' --allow-root 一行解决。完成后刷新对象缓存:wp cache flush,再测。grep -r 'deny from all' /var/www/html,任何 .htaccess 或 nginx.conf 里残留的“小黑屋”指令,立即注释或删除。随后 systemctl restart php-fpm,让进程池彻底重启,把内存里的幽灵指令一起清掉。cd /var/www
tar --exclude='*.log' -czf wordpress.tgz html
mysqldump -u root -p wordpress wordpress.sqlscp wordpress.tgz wordpress.sql user@newhost:/tmp
ssh user@newhost
sudo tar -xzf /tmp/wordpress.tgz -C /var/www
sudo chown -R www-data:www-data /var/www/htmlsudo find /var/www/html -type f -exec chmod 644 {} \;
sudo find /var/www/html -type d -exec chmod 755 {} \;mysql -u root -p
CREATE DATABASE wordpress CHARACTER SET utf8mb4;
EXIT
mysql -u root -p wordpress [/span> /tmp/wordpress.sql
cd /var/www/html
wp search-replace 'https://old.com' 'https://new.com' --allow-root/var/www/html/index.php 存在且不为空。缺失则重新从官方包复制。/etc/nginx/sites-available/wordpressserver {
listen 80;
server_name new.com www.new.com;
root /var/www/html;
index index.php;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
}
}sudo ln -s /etc/nginx/sites-available/wordpress /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginxsudo ufw allow 'Nginx Full'
sudo fail2ban-client status nginx-limit-reqdeny all 或 return 403 的残留配置。sudo systemctl restart php8.2-fpm
wp cache flush --allow-root
curl -I https://new.comHTTP/2 200,即告成功。setsebool -P httpd_can_network_connect 1user.ini 或 .htaccess 干扰。打造老板满意的留言墙:WordPress互动升级指南
解决WordPress迁移403问题的静默攻防策略
地产大亨网购遇阻:WordPress限制地区插件揭秘
小企业数据备份软件:守护企业命脉的守护神
数据库备份秘籍:掌握Firebird的冷备与热备
兼容模式:WordPress的幽默修复之旅
网站429错误,轻松应对技巧分享
打造老板满意的留言墙:WordPress互动升级指南
地产大亨网购遇阻:WordPress限制地区插件揭秘
兼容模式:WordPress的幽默修复之旅
搜索引擎思维下的WordPress图片水印插件防护策略
30分钟学会给WordPress添加悬浮小精灵
DIY模块跨端迁移与二次激活策略解析
WordPress地图插件:提升用户体验与本地SEO
WordPress多站点内容聚合策略与实践
WordPress 里程插件:数据驱动的精准里程计算
让iframe像钱包一样自动伸缩的WordPress教程
赛博松鼠的FTP找坚果历险记:解决FileZilla搜索问题
轻松打造互动留言板:老板教你WordPress留言板设计秘籍