Page 1 of 1

nginx + php-fpm + wordpress + wp super cache

Posted: Tue Oct 10, 2017 1:11 pm
by systemfake
Привет, друзья. Пожалуйста, Помогите!
Я не любитель создавать темы с вопросами, т.к для меня это хобби и предпочитаю разбираться во всем сам (используя google конечно). Когда проблему решаешь сам, после долгих поисков, то и запоминается лучше. Но, уже довольно долго просто не могу побороть одну проблему: на сервере с 1GB оперативки с nginx + php-fpm, стоит wordpress, работает нормально (домен https - lets encrypt). Но! Как только я скачиваю, устанавливаю, активирую и включаю плагин wp super cache, при открытии главной страницы, вижу ошибку 500 (Internal Server Error, внутренняя ошибка сервера). Уже кажется всё перепробовал, но побороть это, увы, никак не получается.
В логах php-fpm - чисто, изредка проскакивает ошибка (ERROR: fork() failed: Cannot allocate memory (12)) но с плагином это не связано.
Админка wordpress при этом нормально работает и открывается, если сделать проверку кэширования выводит:
SpoilerShow

Code: Select all

Проверка страницы http://domain.ru/ в кэше: ЕСТЬ (0.html)
Проверка первой копии http://domain.ru/: ЕСТЬ (1.html)
Проверка второй копии http://domain.ru/: ЕСТЬ (2.html)
Страница 1: 500 (Internal Server Error)
Страница 2: 500 (Internal Server Error)
Страницы не совпадают! Временной штамп отличается или не был найден!
При открытии страницы: Логи nginx:
SpoilerShow

Code: Select all

2017/10/10 19:45:28 [error] 31451#31451: *5 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Call to a member function get() on null in /home/admin/web/domain.ru/public_html/home/wp-includes/cache.php on line 123" while reading response header from upstream, client: 46.241.26.95, server: domain.ru, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9024", host: "domain.ru"
Шаблон для php-fpm пробовал wordpress.stpl и wordpress2.stpl - не работает, в данный момент стоит этот:
SpoilerShow

Code: Select all

server {
    listen      %ip%:%web_ssl_port%;
    server_name %domain_idn% %alias_idn%;
    root        %docroot%;
    index       index.php index.html index.htm;
    access_log  /var/log/nginx/domains/%domain%.log combined;
    access_log  /var/log/nginx/domains/%domain%.bytes bytes;
    error_log   /var/log/nginx/domains/%domain%.error.log error;

    ssl         on;
    ssl_certificate      %ssl_pem%;
    ssl_certificate_key  %ssl_key%;

    set $cache_uri $request_uri;

    # POST requests should always go to PHP
    if ($request_method = POST) {
        set $cache_uri 'null cache';
    }
    # urls with a query string should always go to PHP
    if ($query_string != "") {
        set $cache_uri 'null cache';
    }

    if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php
                          |wp-.*.php|/feed/|index.php|wp-comments-popup.php
                          |wp-links-opml.php|wp-locations.php |sitemap(_index)?.xml
                          |[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
    set $cache_uri 'null cache';
    }  
    
    if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+
                         |wp-postpass|wordpress_logged_in") {
        set $cache_uri 'null cache';
    }

    set $cachefile "/wp-content/cache/supercache/$http_host$cache_uri/index.html";
    if ($scheme = https) {
        set $cachefile "/wp-content/cache/supercache/$http_host$cache_uri/index-https.html";
    }
    
    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    location / {

	gzip_static  on;
        try_files $cachefile $uri $uri/ /index.php?$args;

        location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
            expires     max;
        }

        location ~ [^/]\.php(/|$) {

            fastcgi_buffers 16 16k;
            fastcgi_buffer_size 32k;
            proxy_buffer_size   128k;
            proxy_buffers   4 256k;
            proxy_busy_buffers_size   256k;

            fastcgi_param  PATH_INFO        $fastcgi_path_info;
            fastcgi_read_timeout 600s;
            fastcgi_send_timeout 600s;

            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            if (!-f $document_root$fastcgi_script_name) {
                return  404;
            }

            fastcgi_pass    %backend_lsnr%;
            fastcgi_index   index.php;
            include         /etc/nginx/fastcgi_params;
        }
    }

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

    location /error/ {
        alias   %home%/%user%/web/%domain%/document_errors/;
    }

    location ~* "/\.(htaccess|htpasswd)$" {
        deny    all;
        return  404;
    }

    location /vstats/ {
        alias   %home%/%user%/web/%domain%/stats/;
        include %home%/%user%/web/%domain%/stats/auth.conf*;
    }

    include     /etc/nginx/conf.d/phpmyadmin.inc*;
    include     /etc/nginx/conf.d/phppgadmin.inc*;
    include     /etc/nginx/conf.d/webmail.inc*;

    include     %home%/%user%/conf/web/snginx.%domain_idn%.conf*;
}
Т.е я пробовал без этих значений

Code: Select all

            fastcgi_buffers 16 16k;
            fastcgi_buffer_size 32k;
            proxy_buffer_size   128k;
            proxy_buffers   4 256k;
            proxy_busy_buffers_size   256k;

            fastcgi_param  PATH_INFO        $fastcgi_path_info;
            fastcgi_read_timeout 600s;
            fastcgi_send_timeout 600s;
и с ними... кажется уже все комбинации перепробовал, т.к я пока не особо в этом разбираюсь, то не знаю что еще можно попробовать... может кто тут скажет, куда копать? Заранее спасибо.