Wordpress category links are not working and sometimes PHP gives a blank page on an Nginx server

February 19, 2015 5.3k views

I just configured a new server to move my website. After I migrated, everything works fine except for category links. If we visit a category, it will give a 404 error. Page permalinks are working fine! What might be the problem? One website gives this problem immediately, the other after sometime. Sometimes even the posts go missing.

Sometimes I even get a problem of having blank pages for php files.

The nginx conf :

    server {
            listen   80;


            root /var/www/androidgadgematic;
            index index.php index.html index.htm;

            server_name androidgadgematic.com www.androidgadgematic.com;

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

            location ~* .(jpg|jpeg|png|gif|ico|css|js)$ {
                expires 10d;
            }

            error_page 404 /404.html;
            error_page 500 502 503 504 /50x.html;

            location = /50x.html {
                  root /usr/share/nginx/www;
           }


            location ~ /\. {
                    deny all;
                    access_log off;
                    log_not_found off;
            }

            location ~ /nginx.conf {
                    deny all;
                    log_not_found off;
                    access_log off;
            }

            location ~ ^/feed/(.+)\.html$ {
                    if ($args != '') {
                    rewrite ^(.*) $1? permanent;
                    }
            }

            # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
            location ~ \.php$ {
                    try_files $uri =404;
                    fastcgi_pass unix:/var/run/php5-fpm.sock;
                    fastcgi_index index.php;
                    include fastcgi.conf;
            }

            include /var/www/androidgadgematic/nginx.conf;
            location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" { add_header "" ""; }
            location ~ "^/ngx_pagespeed_static/" { }
            location ~ "^/ngx_pagespeed_beacon$" { }
            location /ngx_pagespeed_statistics { allow 127.0.0.1; deny all; }
            location /ngx_pagespeed_global_statistics { allow 127.0.0.1; deny all; }
            location /ngx_pagespeed_message { allow 127.0.0.1; deny all; }
            location /pagespeed_console { allow 127.0.0.1; deny all; }

            location ^~ /wp-login.php {
                    auth_basic            "Restricted Area: WordPress";
                    auth_basic_user_file  /var/www/.htpasswd;
                    try_files $uri =404;
                    #fastcgi_pass 127.0.0.1:9000;
                    fastcgi_pass unix:/var/run/php5-fpm.sock;
                    fastcgi_index index.php;
                    include fastcgi.conf;
            }

    }

PS : Even the wp-admin gives 404

fastcgi.conf:

    fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
    fastcgi_param  QUERY_STRING       $query_string;
    fastcgi_param  REQUEST_METHOD     $request_method;
    fastcgi_param  CONTENT_TYPE       $content_type;
    fastcgi_param  CONTENT_LENGTH     $content_length;

    fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
    fastcgi_param  REQUEST_URI        $request_uri;
    fastcgi_param  DOCUMENT_URI       $document_uri;
    fastcgi_param  DOCUMENT_ROOT      $document_root;
    fastcgi_param  SERVER_PROTOCOL    $server_protocol;
    fastcgi_param  HTTPS              $https if_not_empty;

    fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
    fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;

    fastcgi_param  REMOTE_ADDR        $remote_addr;
    fastcgi_param  REMOTE_PORT        $remote_port;
    fastcgi_param  SERVER_ADDR        $server_addr;
    fastcgi_param  SERVER_PORT        $server_port;
    fastcgi_param  SERVER_NAME        $server_name;

    # PHP only, required if PHP was built with --enable-force-cgi-redirect
    fastcgi_param  REDIRECT_STATUS    200;

PS : I downloaded and compiled Nginx from source to install page speed. Might this be the problem?

5 comments
1 Answer

i face this problem too, for other post is working perfect but category only show blank pages.. any suggest?

Have another answer? Share your knowledge.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!