Задать вопрос
@goldbase

Почему nginx стал долго грузится сайт, а так же падать через сутки двое?

сервер Apache MPM-Prefork 2.4.6-45.el7.centos , PHP module 5.6.30-1.el7.remi , PHP-FPM 5.6.30-1.el7.remi , awstats 7.4-1.el7 , logrotate 3.8.6-12.el7 , nginx 1.10.2-1.el7.centos.ngx
сайт FastCGI (Nginx + PHP-FPM)
лог журнала

2017/02/19 19:02:04 [error] 2439#2439: *1829 connect() to unix:/var/www/php-fpm/goldbase.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 191.96.249.54, server: volshebnayakarta.tk, request: "POST /xmlrpc.php HTTP/1.0", upstream: "fastcgi://unix:/var/www/php-fpm/goldbase.sock:", host: "79.174.76.93"
2017/02/19 19:02:10 [error] 2439#2439: *1833 connect() to unix:/var/www/php-fpm/goldbase.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 191.96.249.54, server: volshebnayakarta.tk, request: "POST /xmlrpc.php HTTP/1.0", upstream: "fastcgi://unix:/var/www/php-fpm/goldbase.sock:", host: "79.174.76.93"
2017/02/19 19:02:36 [error] 2439#2439: *1845 connect() to unix:/var/www/php-fpm/goldbase.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 191.96.249.54, server: volshebnayakarta.tk, request: "POST /xmlrpc.php HTTP/1.0", upstream: "fastcgi://unix:/var/www/php-fpm/goldbase.sock:", host: "79.174.76.93"
2017/02/19 19:02:38 [error] 2439#2439: *1847 connect() to unix:/var/www/php-fpm/goldbase.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 191.96.249.54, server: volshebnayakarta.tk, request: "POST /xmlrpc.php HTTP/1.0", upstream: "fastcgi://unix:/var/www/php-fpm/goldbase.sock:", host: "79.174.76.93"
2017/02/19 19:02:39 [error] 2439#2439: *1849 connect() to unix:/var/www/php-fpm/goldbase.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 191.96.249.54, server: volshebnayakarta.tk, request: "POST /xmlrpc.php HTTP/1.0", upstream: "fastcgi://unix:/var/www/php-fpm/goldbase.sock:", host: "79.174.76.93"


конфиг сайта

fastcgi_buffer_size 10240k;
fastcgi_buffers 4 10240k;
fastcgi_cache_path /var/lib/nginx/cache levels=2 keys_zone=example:16m max_size=512m inactive=1d;
server {
fastcgi_read_timeout 180;
    server_name volshebnayakarta.tk www.volshebnayakarta.tk;
    charset off;
    index index.html index.php;
    disable_symlinks if_not_owner from=$root_path;
    include /etc/nginx/vhosts-includes/*.conf;
    include /etc/nginx/vhosts-resources/volshebnayakarta.tk/*.conf;
    access_log /var/www/httpd-logs/volshebnayakarta.tk.access.log;
    error_log /var/www/httpd-logs/volshebnayakarta.tk.error.log notice;
    ssi on;
    set $root_path /var/www/goldbase/data/www/volshebnayakarta.tk;
    root $root_path;
    expires 1h;




    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/ /index.php?$args; # permalinks
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
        }

        location ~ \.php$ {
                fastcgi_pass unix:/var/www/php-fpm/goldbase.sock;
                fastcgi_index index.php;
                include fastcgi_params;
        }
    location @php {
        fastcgi_index index.php;
        fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f webmaster@volshebnayakarta.tk";
        fastcgi_pass unix:/var/www/php-fpm/goldbase.sock;
        fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
        try_files $uri =404;
        include fastcgi_params;
    }
    gzip on;
    gzip_comp_level 4;
    gzip_disable "msie6";
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
    listen мой ip :80;
    listen мой ip:80;
}
server {
fastcgi_read_timeout 180;
    server_name volshebnayakarta.tk www.volshebnayakarta.tk;
    ssl on;
    ssl_certificate "/var/www/httpd-cert/goldbase/volshebnayakarta.tk_le1.crtca";
    ssl_certificate_key "/var/www/httpd-cert/goldbase/volshebnayakarta.tk_le1.key";
    ssl_ciphers EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH;
    ssl_prefer_server_ciphers on;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    add_header Strict-Transport-Security "max-age=31536000;";
    charset off;
    index index.html index.php;
    disable_symlinks if_not_owner from=$root_path;
    include /etc/nginx/vhosts-includes/*.conf;
    include /etc/nginx/vhosts-resources/volshebnayakarta.tk/*.conf;
    access_log /var/www/httpd-logs/volshebnayakarta.tk.access.log;
    error_log /var/www/httpd-logs/volshebnayakarta.tk.error.log notice;
    ssi on;
    set $root_path /var/www/goldbase/data/www/volshebnayakarta.tk;
    root $root_path;
    listen [2a01:d8:4:2::50f]:443;
    listen мой ip :443;
    expires 1h;

    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/ /index.php?$args; # permalinks
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
        }

        location ~ \.php$ {
                fastcgi_pass unix:/var/www/php-fpm/goldbase.sock;
                fastcgi_index index.php;
                include fastcgi_params;
        }
    location @php {
        fastcgi_index index.php;
        fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f webmaster@volshebnayakarta.tk";
        fastcgi_pass unix:/var/www/php-fpm/goldbase.sock;
        fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
        try_files $uri =404;
        include fastcgi_params;
    }
    gzip on;
    gzip_comp_level 4;
    gzip_disable "msie6";
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
}


Nginx это конфиг
user  apache;
worker_processes  4;
timer_resolution 100ms;
worker_rlimit_nofile 8192;
worker_priority -5; #Увеличитвваем приоритет

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections  2048;
}


http {


    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip   on;
    gzip_min_length 1100;
    #gzip_disable   "msie6";  #Быстрее, но работает только на новых версиях nginx
    gzip_disable "MSIE [1-6]\.(?!.*SV1)";
    gzip_proxied    any;
    gzip_comp_level 4;
    gzip_types      text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
    gzip_vary       on;

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/vhosts/*/*.conf;
    server {
        server_name localhost;
 disable_symlinks if_not_owner;
    include /etc/nginx/vhosts-includes/*.conf;
    location @fallback {
        error_log /dev/null crit;
        proxy_pass http://127.0.0.1:8080;
        proxy_redirect http://127.0.0.1:8080 /;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        access_log off ;
    }
    listen 80;
    }

}
  • Вопрос задан
  • 1655 просмотров
Подписаться 1 Оценить 4 комментария
Решения вопроса 1
@totosarg
Проверял? Проверял. Работает? Работает. Не трогай!
Есть несколько причин почему PHP-FPM достигает максимума в pm.max_children: слишком много паралелльных запросов, слишком медленно выполняются скрипты, или слишком маленькое значение.... увеличте max_children, только следите чтоб у вас памяти хватило на все.
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы