0

My wordpress site has been working fine for sometime with nginx and wordpress. But for some reason it is now giving me a 404 error. I think this may be related to the quick-cache plugin which I recently updated. Although I'm not 100% sure about this.

To setup wp-nginx I following these instructions. So far I've done the following

  • deleted my plugin directory
  • removed reference to quick-cache from wp-config.php /wp-content folder
  • checked my nginx config which is below

However after restarting I still get the same 404 error. Would anyone know what could be wrong..?

server {
    listen   80;


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

    server_name mysite.com;

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

    error_page 404 /404.html;

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

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

}

1 Answer 1

-1

Your config is not okay.

Here is working WordPress config file.

server {
                listen 80;
                server_name www.mysite.com mysite.com;
                access_log /var/log/nginx/mysite.access.log;
                error_log /var/log/nginx/mysite.error.log;
                root /var/www/html;
                index index.php index.htm index.html;

location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
        }
location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?q=$uri&$args;
}

location ~ /\. {
    access_log off;
    log_not_found off; 
    deny all;
}
location /favicon.ico { access_log off; log_not_found off; }
location ~* \.(jpg|jpeg|gif|png|js|xml)$ {
    access_log        off;
    log_not_found     off;
    expires           360d;
}
                location ~ .php$ {
                  fastcgi_pass 127.0.0.1:9000;
                  fastcgi_index index.php;
                  fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name;
                  include fastcgi_params;
                }
       }
2
  • 2
    Your suggested config has a different root and a different method for talking to the CGI process. Do you have any reason to believe these would work on the OP's server? You also make loads of other changes without explaining which of them might actually solve the problem or any side effects they may have. For instance, he's going to find that his access logs suddenly don't have any static files in them any more if he uses this config. Could you edit your answer to just focus on the actual problem and not create any new ones?
    – Ladadadada
    Oct 6, 2014 at 16:17
  • This would work like a charm. fastcgi_pass 127.0.0.1:9000; this line can be changed to php-fpm.sock . I use that config. Never faced any problem. 1st question config does not contain any error logs or access logs code. My Cofig file is complete code. 2nd this main code is missing. fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name;
    – Kavin
    Oct 6, 2014 at 16:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .