WordPress错误404在从Apache到Nginx的迁移中

发布于 2025-01-27 05:15:18 字数 1212 浏览 3 评论 0原文

我在Apache服务器上安装了一个工作的WordPress安装,并想在VPS上迁移到NGINX服务器。我复制了所有文件,设置了MSQL连接等。除了已发表的文章,所有文件似乎都很好,所有这些文章都会产生404个错误。管理区工作正常,没有明显的问题。

虚拟服务器配置是:

server {
if ($host = www.xxx.es) {
return 301 https://$host$request_uri;
} # managed by Certbot


listen 80;
server_name xxx.es www.xxx.es;
return 301 https://www.xxx.es$request_uri;}

server {
server_name  xxx.es www.xxx.es;
root /home/www/xxx.es/html/;
index index.php;

#listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/www.xxx.es/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/www.xxx.es/privkey.pem; # managed byCertbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

 location ~ [^/]\.php(/|$) {
 fastcgi_split_path_info ^(.+?\.php)(/.*)$;
 if (!-f $document_root$fastcgi_script_name) {return 404;}


 fastcgi_param HTTP_PROXY "";
 fastcgi_pass unix:/run/php/php7.2-fpm.sock;
 fastcgi_index index.php;
 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 include fastcgi_params;

 }

我尝试了其他问题的解决方案,但没有成功。感谢您的帮助

I have a working WordPress installation on an Apache server and wanted to migrate to an NGINX server on a VPS. I've copied all the files, set up the MSQL connection, etc. and everything seems to work fine except the published articles, which all give 404 errors. The admin area works fine, with no apparent problems.

The virtual server configuration is:

server {
if ($host = www.xxx.es) {
return 301 https://$host$request_uri;
} # managed by Certbot


listen 80;
server_name xxx.es www.xxx.es;
return 301 https://www.xxx.es$request_uri;}

server {
server_name  xxx.es www.xxx.es;
root /home/www/xxx.es/html/;
index index.php;

#listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/www.xxx.es/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/www.xxx.es/privkey.pem; # managed byCertbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

 location ~ [^/]\.php(/|$) {
 fastcgi_split_path_info ^(.+?\.php)(/.*)$;
 if (!-f $document_root$fastcgi_script_name) {return 404;}


 fastcgi_param HTTP_PROXY "";
 fastcgi_pass unix:/run/php/php7.2-fpm.sock;
 fastcgi_index index.php;
 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 include fastcgi_params;

 }

I have tried the solutions of other questions without success. Thanks for the help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浪漫之都 2025-02-03 05:15:18

尝试改变您的部分:

location ~ [^/]\.php(/|$) {
    fastcgi_split_path_info ^(.+?\.php)(/.*)$;
    if (!-f $document_root$fastcgi_script_name) {return 404;}

    fastcgi_param HTTP_PROXY "";
    fastcgi_pass unix:/run/php/php7.2-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

}

对此:

location / {
    try_files $uri $uri/ /index.php?q=$uri&$args;
}

location ~ \.php$ {
    try_files $uri =404;
    fastcgi_pass unix:/run/php/php7.2-fpm.sock;
    fastcgi_index index.php;

    include fastcgi_params;
}

location ~ /\. {
    deny all;
}

location ~* /(?:uploads|files)/.*\.php$ {
    deny all;
}

Try to change your part:

location ~ [^/]\.php(/|$) {
    fastcgi_split_path_info ^(.+?\.php)(/.*)$;
    if (!-f $document_root$fastcgi_script_name) {return 404;}

    fastcgi_param HTTP_PROXY "";
    fastcgi_pass unix:/run/php/php7.2-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

}

to this one:

location / {
    try_files $uri $uri/ /index.php?q=$uri&$args;
}

location ~ \.php$ {
    try_files $uri =404;
    fastcgi_pass unix:/run/php/php7.2-fpm.sock;
    fastcgi_index index.php;

    include fastcgi_params;
}

location ~ /\. {
    deny all;
}

location ~* /(?:uploads|files)/.*\.php$ {
    deny all;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文