Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

500 error with Nginx and WordPress pretty permalinks

Ran into a 500 issue when running Nginx and WP together and setting pretty permalinks. I've been trying a bunch of different methods from Google but none seems to help.

Config -

server {
        listen   80;

        root /var/www/mydomain.com/public_html;
        index index.php index.html index.htm;

        server_name .mydomain.com;

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

        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;

        }
}

All files load perfectly well, and the pages work if using the default permalinks setting. Strange thing is, if I check the network log I first see a 200 OK being received, then immediately followed by a 500. Any ideas?

Edit: Setting to close as I'm switching to Apache instead. Will mark correct answer as it seems to have helped others.

like image 991
Staffan Estberg Avatar asked Dec 08 '22 07:12

Staffan Estberg


1 Answers

try:

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

AND:

fastcgi_index /index.php;

(note the / )

like image 189
Rufinus Avatar answered Dec 11 '22 11:12

Rufinus