这是我的第一个问题! 几天前,我发现nginx出了点问题:域AC好,其他的超时。 之后:其他域名可以,第一次超时; 或者每个域都工作正常。 如果我重新启动nginx – 没有任何改变。 重新启动后,一切正常。
也许是因为有时候访问者和nginx的连接太多而无法处理? (以前有一个Apache,它偶尔冻结VDS)。 但是在日志中没有错误,没有什么。 在最高输出中,我看到只有2-4mb的交换空间被使用。
它是:arch linux,nginx,php-fpm。
configuration文件:用户http http;
worker_processes 1; error_log /var/log/nginx/nginx.error.log; events { worker_connections 2048; } http { include mime.types; default_type application/octet-stream; error_log /var/log/nginx/http.error.log; sendfile on; gzip on; gzip_static on; gzip_vary on; client_body_buffer_size 1k; client_header_buffer_size 1k; client_max_body_size 5m; large_client_header_buffers 2 1k; client_body_timeout 10; client_header_timeout 10; keepalive_timeout 5 5; send_timeout 10; server { listen 80; server_name www.A.com www.B.org www.F.net; if ($host ~* ^www\.(.+)) {set $domain $1;} return 301 $scheme://$domain$request_uri; } server { listen 80; server_name A.com *.A.com B.org F.net; root /home/user/public_html/$host; access_log /var/log/nginx/$host-access.log; error_log /var/log/nginx/server.error.log; location / { try_files $uri $uri/ /index.php?$args; index index.html index.htm index.php; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 location ~ \.php$ { fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; try_files $uri =404; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } }
当然,我认为我必须find原因,不仅解决问题。
非常感谢!
尝试增加worker_connection服务。 或者,如果你有超过1个核心 – 将worker_processes增加到核心数量。
这可能会帮助你…从Nignx维基
client_body_buffer_size语法:client_body_buffer_size size默认值:8k | 16k上下文:http服务器位置参考:client_body_buffer_size
该指令指定客户端请求主体缓冲区大小。
如果请求主体大小大于缓冲区大小,则整个(或部分)请求主体被写入临时文件。
默认大小等于页面大小乘以2.根据平台,页面大小是8K或16K。
当Content-Length请求头指定比缓冲区大小小的值时,Nginx会使用较小的值。 因此,Nginx并不总是为每个请求分配一个缓冲区大小的缓冲区。
使用accept_mutex on序列化请求可能也有帮助…我通常也检查php-fpm日志。 最好的办法是检查服务器如何以及为什么不服务预定页面的行为。 日志是我们这里唯一的朋友,所以,如果你知道服务器没有响应请求的时间,日志中可能会有一些东西。
哦, Nginx reload可以做到这一点,而不是restart ,这将暂停服务一段时间。
如果你有类似的东西 – 尝试tracert和检查DNS。 我不确定,但最有可能我们的问题是与DNS服务器。