500 with Nginx and WordPress with pretty permalinks

When starting Nginx and WP along with setting pretty permalinks, there is a 500 problem. I tried a bunch of different methods from Google, but no one helps.

Configuration -

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 fine, and pages work if you use the default permalink setting. It’s strange if I check the network log, I will first see the 200 OK that I received, and then immediately 500. Any ideas?

Edit: setting to close when I switch to Apache. Check the correct answer as it seems to have helped others.

+4
source share
2 answers

to try:

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

and

fastcgi_index /index.php;

(pay attention to/)

+9

.

. . nginx , . , .

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

fastcgi_parm.

. Nginx Config.

/home/public_html .

fastcgi_param SCRIPT_FILENAME /home/public_html$fastcgi_script_name;

wordpress. , . Nginx URL-.

server {
                listen 80;
                server_name example.com;
                root /home/public_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 /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 ~ /\. {
    access_log off;
    log_not_found off; 
    deny all;
}


location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/public_html$fastcgi_script_name;
include fastcgi_params;
}
 }
+4

Source: https://habr.com/ru/post/1542506/


All Articles