Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the commands of FastCGI in Nginx configuration?

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

Nginx configuration of several FastCGI commands are, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.

Nginx configuration has always been used in the work of programmers, and there are many problems we need to learn, among which there are many problems we need to solve in FastCGI. Here are a few instructions about FastCGI configuration in Nginx:

Fastcgi_cache_path / usr/local/Nginx/fastcgi_cache

Levels=1:2 keys_zone=TEST:10m inactive=5m

This directive specifies a path, directory structure level, keyword area storage time, and inactive delete time for Nginx configuration FastCGI cache.

Fastcgi_connect_timeout 300

Specifies the timeout for connecting to the backend FastCGI.

Fastcgi_send_timeout 300

The timeout for sending the request to the FastCGI, which refers to the timeout for sending the request to the FastCGI after two handshakes have been completed.

Fastcgi_read_timeout 300

The timeout for receiving FastCGI replies, which is the timeout for receiving FastCGI replies after two handshakes have been completed.

Fastcgi_buffer_size 4k

Specify the buffer size needed to read the FastCGI reply * part. Generally, the * part of the reply will not exceed 1k. Since the page size is 4k, it is set to 4k here.

Fastcgi_buffers 8 4k

Specify how many and how many buffers are needed locally to buffer FastCGI replies.

Fastcgi_busy_buffers_size 8k

I don't know what this instruction is for, except that the default value is twice that of fastcgi_buffers.

Fastcgi_temp_file_write_size 8k

How many blocks will be used when writing to fastcgi_temp_path? the default value is twice that of fastcgi_buffers.

Fastcgi_cache TEST

Turn on the FastCGI cache and give it a name. Personally, I find it very useful to turn on caching, which can effectively reduce the CPU load and prevent 502 errors.

Fastcgi_cache_valid 200 302 1h; fastcgi_cache_valid 301 1d; fastcgi_cache_valid any 1m

Specify the caching time for the specified reply code, as in the example above, 200302 replies are cached for 1 hour, 301 responses for 1 day, and others for 1 minute.

Fastcgi_cache_min_uses 1

The minimum number of times to cache the inactive parameter value of the fastcgi_cache_path directive. As in the example above, if a file is not used once in 5 minutes, the file will be removed.

Fastcgi_cache_use_stale error timeout invalid_

Header http_500

Not knowing what this parameter does, the guess is to let Nginx know which types of caches are useless.

The above parameters are related to FastCGI in the Nginx configuration. In addition, FastCGI also has some configurations that need to be optimized. If you use php-fpm to manage FastCGI, you can modify the following values in the configuration file:

sixty

The number of concurrent requests processed at the same time, that is, it will open up to 60 child threads to handle concurrent connections.

102400

The maximum number of open files.

204800

The maximum number of requests each process can execute before resetting.

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report