有时服务器响应时间太长,等待(TTFB)30 秒以上,这是 ngnix 服务器设置。我安装错了什么吗?
server {
server_name pitamyshawarma.com www.pitamyshawarma.com
server_name_in_redirect off;
access_log /var/log/nginx/localhost.access_log;
error_log /var/log/nginx/localhost.error_log info;
root /var/www/pitamyshawarma.com/html;
index index.php index.html index.htm default.html default.htm;
# Support Clean (aka Search Engine Friendly) URLs
location / {
try_files $uri $uri/ /index.php?$args;
}
# deny running scripts inside writable directories
location ~* /(images|cache|media|logs|tmp)/.*\.(php|pl|py|jsp|asp|sh|cgi)$ {
return 403;
error_page 403 /403_error.html;
}
location ~ \.php$ {
fastcgi_cache phpcache; # The name of the cache key-zone to use
fastcgi_cache_valid 200 30m; # What to cache: 'Code 200' responses, for half an hour
fastcgi_cache_methods GET HEAD; # What to cache: only GET and HEAD requests (not POST)
add_header X-Fastcgi-Cache $upstream_cache_status; # Add header so we can see if the cache hits or misses
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}
# caching of files
location ~* \.(ico|pdf|flv)$ {
expires 1y;
}
location ~* \.(js|css|png|jpg|jpeg|gif|swf|xml|txt)$ {
expires 14d;
}
listen 443 ssl http2; # managed by Certbot
*** 这里有很多 SSL 工作人员
}
server {
if ($host = www.pitamyshawarma.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = pitamyshawarma.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name pitamyshawarma.com www.pitamyshawarma.com
server_name_in_redirect off;
return 404; # managed by Certbot
}