Nginx error prompt: 504 gateway time-out solution

Source: Internet
Author: User

My friend said that the error message 504 gateway time-out has nothing to do with nginx itself. We can solve this problem by adjusting the FastCGI configuration parameters.

.

Modify the PHP-FPM configuration file:

1. Modify max_children according to the system to ensure that there are sufficient PHP-CGI processes available;

Modify the PHP-FPM configuration file to increase the number of PHP-CGI Processes

Modify the number of PHP-CGI processes:

The Code is as follows:
6/usr/local/PHP/etc/php-fpm.conf

Find:

<Value name = "max_children"> 5 </value>

Find the number of PHP Processes Modified according to your memory capacity. Generally, 6 PHP processes are enabled for 128 of the memory, and 16 PHP processes are enabled for 256 of the memory. This ensures high concurrency in PHP.

No 502 error. A process occupies 12m-20m, and the specific number of opened processes depends on the memory size.

Max_children is used to set the number of FastCGI processes. According to official recommendations, servers with less than 2 GB of memory can only enable 64 (www.111cn.net) processes, with more than 4 GB of memory.

The server can start 200 processes.

2. Change request_terminate_timeout to 60 s, so that the timeout time for the PHP-CGI process to process the script is 60 seconds, which can prevent the process from being suspended.

To improve utilization efficiency.

Modify the nginx. conf file as follows:

The Code is as follows:
Fastcgi_connect_timeout 60;

Fastcgi_send_timeout 180;

Fastcgi_read_timeout 180;

Fastcgi_buffers' 4 256 K;

Fastcgi_buffer_size 128 K;

Fastcgi_busy_buffers_size 256 K;

Fastcgi_temp_file_write_size 256 K;

Fastcgi_intercept_errors on;

Then restart your server/etc/init. d/PHP-FPM restart to solve the problem.
From: http://www.111cn.net/sys/nginx/45338.htm

Nginx error prompt: 504 gateway time-out solution

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.