S
S
sarkisssik2022-01-19 09:12:59
Nginx
sarkisssik, 2022-01-19 09:12:59

What's wrong with the FastCGI (Nginx + PHP-FPM) config?

7 X Intel(R) Xeon(R) E-2288G CPU @ 3.70GHz RAM 14gb
FastCGI (Nginx + PHP-FPM) php 5.6.4 Everything

was fine at first, but lately I've noticed that the site started to work slowly. There is no load on the system.
Even if you run empty scripts with the text Hello World, they are processed for a very long time. 1-2 sec.
Tell me what needs to be adjusted or what to pay attention to?

If the site is switched to apache, then everything works quite quickly.

server {



  server_name мой_сайт.ru *.мой_сайт.ru www.мой_сайт.ru;
  charset UTF-8;
  index index.php index.html;
  disable_symlinks if_not_owner from=$root_path;
  include /etc/nginx/vhosts-includes/*.conf;
  include /etc/nginx/vhosts-resources/мой_сайт.ru/*.conf;
  access_log /var/www/httpd-logs/мой_сайт.ru.access.log;
  error_log /var/www/httpd-logs/мой_сайт.ru.error.log notice;
  
  return 301 https://$host:443$request_uri;
  

  
  
  
  
  
  set $root_path /var/www/мой_сайт.ru/data/www/мой_сайт.ru;
  location / {
    location ~ [^/]\.ph(p\d*|tml)$ {
      try_files /does_not_exists @php;
    }
    location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
      expires 7d;
    }
  }
  
  
   return 301 https://$host$request_uri;
  
  return 301 https://$host:443$request_uri;
  root $root_path;
  gzip on;
  gzip_comp_level 6;
  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 37.333.117.333:80 default_server;
  location @php {
    fastcgi_index index.php;
    fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f [email protected]мой_сайт.ru";
    fastcgi_pass unix:/var/www/php-fpm/1.sock;
    fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
    try_files $uri =404;
    include fastcgi_params;
  }
}



server {


  

  server_name мой_сайт.ru *.мой_сайт.ru www.мой_сайт.ru;
  ssl_certificate "/var/www/httpd-cert/мой_сайт.ru/мой_сайт.ru_custom_1.crtca";
  ssl_certificate_key "/var/www/httpd-cert/мой_сайт.ru/мой_сайт.ru_custom_1.key";
  ssl_ciphers EECDH:+AES256:-3DES:RSA+AES:!NULL:!RC4;
  ssl_prefer_server_ciphers on;
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  ssl_dhparam /etc/ssl/certs/dhparam4096.pem;
  charset UTF-8;
  index index.php index.html;
  disable_symlinks if_not_owner from=$root_path;
  include /etc/nginx/vhosts-includes/*.conf;
  include /etc/nginx/vhosts-resources/мой_сайт.ru/*.conf;
  access_log /var/www/httpd-logs/мой_сайт.ru.access.log;
  error_log /var/www/httpd-logs/мой_сайт.ru.error.log crit;
  set $root_path /var/www/мой_сайт.ru/data/www/мой_сайт.ru;
  
  error_page 404 /index.php?error;

    #return 301 https://$host:443$request_uri;









    if ($request_uri ~* "^/index\.php$") {
       return 301 /;
   }




    if ($host ~* www\.(.*)) {
        set $host_without_www $1;
        rewrite ^(.*)$ https://$host_without_www$1 permanent;
    }








  location / {
    location ~ [^/]\.ph(p\d*|tml)$ {
      try_files /does_not_exists @php;
    }
    location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
      expires 7d;
    }
    

  
  
  }
  
  

        


     	
  
  
  root $root_path;

    if ($host != $server_name) {
      return 444;
     }


  gzip on;
  gzip_comp_level 6;
  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;
  error_log /var/www/httpd-logs/мой_сайт.ru.error.log notice;
  listen 37.333.117.333:443 ssl default_server;
  location @php {
    fastcgi_index index.php;
    fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f [email protected]мой_сайт.ru";
    fastcgi_pass unix:/var/www/php-fpm/1.sock;
    fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
    try_files $uri =404;
    include fastcgi_params;
  }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
ky0, 2022-01-19
@ky0

Does Apache also work with FPM or does it work with a module? If so, it's in the PHP settings.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question