【问题标题】:Wordpress on NGINX opens white pages :(NGINX 上的 Wordpress 打开白页 :(
【发布时间】:2018-08-03 16:43:18
【问题描述】:

我在 Windows 上开发了一些 wordpress 网站,它运行良好,没有任何问题。现在我需要迁移到带有 Nginx 和 PHP 7.2 的 Ubuntu 18.04 服务器。

我都是按照手册来做的,但是任何 wordpress 页面都以空白页打开:( 我通过使用 phpinfo() 添加到主文件夹 phpinfo.php 来测试它;代码,它打开没有问题,因为 domain/phpinfo.php,图像和 html 文件也打开没有问题,作为 domain/image.png 或 domain/file.html。

最糟糕的是我没有收到任何错误:(

这是我的域配置:

 map $uri $blogname{
~^(?P<blogpath>/[^/]+/)files/(.*)       $blogpath ; }

map $blogname $blogid{
default -999;

#Ref: http://wordpress.org/extend/plugins/nginx-helper/
#include /var/www/wordpress/wp-content/plugins/nginx-helper/map.conf ; }

server {
server_name domain;

root /srv/domain;
index index.php;
access_log /var/log/nginx/domain.access.log;
error_log /var/log/nginx/domain.error.log;

location ~ ^(/[^/]+/)?files/(.+) {
    try_files /wp-content/blogs.dir/$blogid/files/$2 /wp-includes/ms-files.php?file=$2 ;
    access_log off;     log_not_found off; expires max;
}

#avoid php readfile()
location ^~ /blogs.dir {
    internal;
    alias /srv/domain/htdocs/wp-content/blogs.dir ;
    access_log off;     log_not_found off; expires max;
}

if (!-e $request_filename) {
    rewrite /wp-admin$ $scheme://$host$uri/ permanent;
    rewrite ^(/[^/]+)?(/wp-.*) $2 last;
    rewrite ^(/[^/]+)?(/.*\.php) $2 last;
}

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

location ~ \.php$ {     fastcgi_split_path_info ^(.+\.php)(/.+)$;   fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
    try_files $uri =404;    fastcgi_index index.php;    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi.conf;
}

#add some rules for static content expiry-headers here }

这是我的 nginx.conf 文件:

user www-data; worker_processes auto; pid /run/nginx.pid; include /etc/nginx/modules-enabled/*.conf;

events {    worker_connections 768; }

http {


ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE  ssl_prefer_server_ciphers on;

access_log /var/log/nginx/access.log;   error_log /var/log/nginx/error.log;

gzip on;

include /etc/nginx/conf.d/*.conf;   include /etc/nginx/sites-enabled/*; }

提前致谢

【问题讨论】:

    标签: php wordpress nginx


    【解决方案1】:

    因为 phpinfo() 和 html 页面都在工作。这可能是 WordPress 白屏死机 (WSOD) 问题。

    • WP_DEBUG 功能通常会提供更多信息。

    请问您是否可以访问 wp-admin 区域?

    https://www.domain/wp-admin
    

    如果是,请尝试以下操作:

    • 插件导致兼容性问题。如果您可以访问 管理屏幕尝试停用所有插件,然后 一一重新激活它们。如果您无法访问您的 屏幕,通过 FTP 登录到您的网站。找到文件夹 wp-content/plugins 并重命名插件文件夹 plugins_old。这个 将停用您的所有插件。您可以阅读更多关于手动 在故障排除常见问题解答中停用您的插件。
    • 您的主题可能会导致问题。如果 你刚刚经历了白屏死机 激活新主题,或在 WordPress 网络中创建新站点。 登录到管理屏幕并激活默认设置 WordPress 二十十六主题。如果您无法访问您的 管理屏幕,通过 FTP 访问您的网站并导航到 /wp-content/themes/ 文件夹。重命名活动文件夹 主题。
    • 您的主题目录可能丢失或重命名。这是常见的 刚刚创建本地开发环境的开发人员和 克隆数据库,它指向一个主题(或主题 目录)可能丢失或重命名。要测试此解决方案, 尝试访问 wp-login.php 或 /wp-admin/。如果你看到什么,这 很好地表明它与主题相关。以管理员身份登录, 然后尝试查看前端,您应该会看到 WordPress 错误 消息的大意是:主题目录“{theme-name}”没有 存在。您可以通过多种方式解决此问题,包括切换 管理端的主题、重命名目录或编辑 wp_options 中的“主题”和“样式表”记录

    来源:https://codex.wordpress.org/Common_WordPress_Errors

    谢谢!

    【讨论】:

    • 感谢您的回答。不,/wp-admin 不起作用,因为任何 wp 页面都不起作用 :( 我在 wp-config.php "define('WP_DEBUG', true);" 中定义,如果我输入 "define('WP_DEBUG', false) ;" 那么即使是白页也打不开
    • 您的 wp-config 设置是否包含新更改 - 它可能无法找到您的数据库?
    • 不,使用数据库连接一切正常。当我输入错误的密码进行测试时,我得到“建立数据库连接时出错”,当我输入正确的密码时,我得到白页:(也许我应该安装 Ubuntu 16.04 和 PHP 7.0 并再试一次?
    【解决方案2】:

    在另一个端口 8080 与 NGINX 一起安装了 apache2,但问题仍然存在 :(

    图像打开,非 wordpress php 文件打开,html 打开,但 Wordpress 没有打开任何页面...

    【讨论】:

    • 重命名插件文件夹。每次我看到白屏都是插件导致的问题。
    • 是啊兄弟!重命名插件文件夹时出现错误。问题是没有安装 php-curl。
    • 非常感谢!非常感谢您的帮助
    猜你喜欢
    • 2017-07-21
    • 2017-06-25
    • 2012-09-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多