nginx 上默认服务器的空白 wordpress 页面

nginx 上默认服务器的空白 wordpress 页面

我最近升级到 php 5.3 以便使用 php-fpm。除了默认网站显示空白页外,我的所有网站都正常运行。在 nginx.conf 中定义如下。此配置有什么问题。错误日志似乎没有报告任何内容。

user              nginx;
worker_processes  1;
error_log         /var/log/nginx/error.log;
pid               /var/run/nginx.pid;
events {
    worker_connections  2048;
}
http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;
    index  index.html index.htm index.php;
    log_format  main  '$remote_addr - $remote_user [$time_local] $request '
                      '"$status" $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
    access_log  /var/log/nginx/access.log  main;

    sendfile        on;

    keepalive_timeout  65;

    client_max_body_size 4M;

    server {
        listen       80;
        server_name  mysite.net.au 111.118.171.66;
        root /usr/share/nginx/html;

        location ~* ^.+\.(xml|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|swf)$
        {
                rewrite ^/files(/.*)$ /wp-content/blogs.php?file=$1 last;
                access_log off;
                expires max;
                break;
        }
        location / {
            if (!-e $request_filename) {
                rewrite ^.+/?(/wp-.*) $1 last;
                rewrite ^.+/?(/.*\.php)$ $1 last;
                rewrite ^(.+)$ /index.php?q=$1 last;
            }

        }

        error_page  404              /404.html;
        location = /404.html {
        }

       error_page   500 502 503 504  /50x.html;
        location = /50x.html {
        }


        location ~ \.php$ {
            #rewrite ^/.*(/wp-.*/.*.php)$ $1;
            fastcgi_pass   php;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        /etc/nginx/fastcgi_params;
            }
    }
server {
        server_name www.mysite.net.au;
        rewrite ^/(.*) http://mysite.net.au/$1 permanent;
    }

    include /etc/nginx/conf.d/*.conf;

}

答案1

将位置/块中的重写规则更改为:

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

并解决安全漏洞将其添加到 ~.php 块的第一行

try_files $uri =404;

相关内容