A 502 error occurs during continuous refresh of wordpress in the nginx system.

Source: Internet
Author: User
Tags ini

If you encounter a 502 problem in nginx, you can take the following two steps as a priority.

1. Check whether the current PHP FastCGI Process count is sufficient:

The code is as follows: Copy code

Netstat-anpo | grep "php-cgi" | wc-l

If the number of FastCGI processes actually used is close to the preset number of FastCGI processes, it indicates that the number of FastCGI processes is insufficient and needs to be increased.

2. If the execution time of some PHP programs exceeds the Nginx waiting time, you can add the FastCGI timeout time in the nginx. conf configuration file, for example:

The code is as follows: Copy code

 
......
Http
{
......
Fastcgi_connect_timeout 300;
Fastcgi_send_timeout 300;
Fastcgi_read_timeout 300;
......
}
......

In php. ini, if memory_limit is set to low, an error will occur. After modifying memory_limit of php. ini to 64 MB, restart nginx and check that PHP memory is insufficient.

My VPS architecture is lnmp solution:

Using Nginx to limit the number of concurrent connections of a single IP address can reduce the number of collection programs or DDOS attacks.
Some code has been added to nginx configuration of lnmp, but it is commented out. You can edit the/usr/local/nginx/conf/nginx. conf file.
Search:

The code is as follows: Copy code


# Limit_zone oneip $ binary_remote_addr 10 m;

Remove the previous #. If this line does not exist, add

The code is as follows: Copy code


Limit_zone oneip $ binary_remote_addr 10 m;

Add

The code is as follows: Copy code

Limit_conn oneip 20;

The number at the end of the limit_conn statement is the maximum number of concurrent connections of a single IP address.

The code is as follows: Copy code

If it is not lnmp installed, it is also very easy to add in nginx. conf

Limit_zone oneip $ binary_remote_addr 10 m;
Limit_conn oneip 20;

Of course, the limit_conn oneip 20 statement can also be added to the server segment to only limit the number of virtual hosts.

Limit the number of concurrent connections directly in the server segment by adding limit_rate 100 k;
The speed of each connection is limited to 100 kB. This limit is for a single thread. For example, if I use IE to download 100 kB, it will occupy 2 threads when I use thunder, therefore, the downloading speed of Thunder is 200 kb. If the concurrency of a single IP address is set to 20, the speed of multi-thread downloading can reach KB × 20.

Restart nginx.

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.