Проблема с wordpress на nginx

28 views
Skip to first unread message

Евгений Левада

unread,
Jul 8, 2015, 12:12:35 AM7/8/15
to ru-wor...@googlegroups.com
Добрый день!

Сайт переехал с апача на нжинкс.

Все страницы сайта нормально открываются и редиректятся.

Перестала открываться админка.

Т.е. при попытке перейти на адрес mysite.com/wp-admin или mysite.com/wp-login.php

Если вернуть все на апач - админка открывается.

В зависимости от конфига нжинкса, в браузер возвращается такое:
- циклическая переадресация;
- страница не найдена;
- 500 Internal Server Error:
- в адресной строке указан адрес mysite.com/wp-admin, но по факту главная страница.

Для большей ясности, привожу конфиг локалхоста нжинкс, когда получаю 500 Internal Server Error:

server {
listen 80;
server_name mysite.com;
access_log /var/log/nginx/www.mysite.com_log;
error_log /var/log/nginx/www.mysite.com-error_log;
set $root_path '/usr/local/www/data/mysite.com';
location / {
try_files $uri @wordpress;
}
location @wordpress {
fastcgi_pass x.x.x.x:9000;
fastcgi_param SCRIPT_FILENAME $root_path/index.php;
include fastcgi_params;
}
location /wp-admin {
try_files $uri $uri/ /wp-admin/index.php?$args;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/local/www/nginx-dist;
}
location ~ /\.ht {
deny all;
}
}

Вот что в логах nginx:

2015/07/07 07:13:08 [error] 12592#0: *3 rewrite or internal redirection cycle while internally redirecting to "/wp-admin/index.php", client: 192.168.2.113,
server: mysite.com, request: "GET /wp-admin HTTP/1.1", host: "mysite.com"

Подскажите что-нибудь т.к. на офф.форуме отмолчались.
Спасибо!

atomdev

unread,
Jul 8, 2015, 3:46:13 AM7/8/15
to ru-wor...@googlegroups.com
Добрый день, конфиг ngix не совсем то что нужно. Какая версия ngix? Пришлю вам рабочий конфиг.

atomdev

unread,
Jul 8, 2015, 3:46:47 AM7/8/15
to ru-wor...@googlegroups.com

Евгений Левада

unread,
Jul 8, 2015, 4:06:15 AM7/8/15
to ru-wor...@googlegroups.com
nginx version: nginx/1.8.0

среда, 8 июля 2015 г., 10:46:13 UTC+3 пользователь atomdev написал:

Евгений Левада

unread,
Jul 9, 2015, 3:08:39 AM7/9/15
to ru-wor...@googlegroups.com
Разобрался. 
Как обычно разработчики радуют своими официальными конфигами.
Вот, конфиг nginx для wordpress 4.2.2 - может кому пригодится:

server {
        listen      80;
        server_name  mysite.com;
        access_log  /var/log/nginx/www.mysite.com_log;
        error_log /var/log/nginx/www.mysite.com-error_log;
        root /usr/local/www/data/mysite.com;
        index index.php;
        gzip on;
        gzip_disable "msie6";
        gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/ja
        location ~ /\. {
                deny all;
        }
        location ~* /(?:uploads|files)/.*\.php$ {
                deny all;
        }
        location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$
                access_log off;
                log_not_found off;
                expires max;
        }
        location / {
                try_files $uri $uri/ @wordpress;
                index index.php index.html index.htm;
        }
        location ~ \.php$ {
                try_files $uri @wordpress;
                fastcgi_pass unix:/tmp/php-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                include fastcgi_params;
        }
        location @wordpress {
                fastcgi_pass unix:/tmp/php-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param  SCRIPT_FILENAME  $document_root/index.php;
                include fastcgi_params;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
             root   /usr/local/www/nginx-dist;
        }
    }

среда, 8 июля 2015 г., 11:06:15 UTC+3 пользователь Евгений Левада написал:
Reply all
Reply to author
Forward
0 new messages