Lnmpa encountered 504 Gateway time-out error resolution

Source: Internet
Author: User

Nginx is characterized by the handling of static is very strong, Apache is the characteristic of processing dynamic is very stable, the combination of the two is Lnmpa,nginx processing front end, Apache processing the backend, so the processing of static will soon, processing dynamics will be very stable. When I think the installation is finished, and behold, when the site was updated 504 Gateway time-out; At first, I thought it was accidental, after many attempts, it still happens, so I decided to find a solution.  LNMP Face 504 Gateway time-out     Because 504 Gateway time-out is Nginx's exclusive error, so at first I thought it was nginx configuration error, find the online tutorial, find the corresponding solution, The following is a brief talk about the solution that LNMP faces in this situation. Nginx this error, because the number of php-cgi process is too limited, in the face of the update site such operations, it is likely that the process is not sufficient to time out, so you want to modify the two files involved in processing time.     First is the nginx.conf file, this file in/nginx/conf/nginx.conf, opened after the main modification of the previous several times, the proposed modification to 120 seconds or more. As for what tool to modify, recommend online command line editing, or download it with WINSCP and modify it with Dreamweaver.  fastcgi_connect_timeout 300s;  fastcgi_send_timeout 300s;  fastcgi_read_timeout 300s;  fastcgi_buffer_size 128k;  fastcgi_buffers 8 128k; #8  fastcgi_busy_buffers_size 256k;  fastcgi_temp_file_write_size 256k; Second to modify the php-fpm.conf file, this file is/php-5.2.17/etc/ Php-fpm.conf, different one-click Install package location is different, anyway, look for PHP installation files under the ETC folder, online editing or download down with Dreamweaver editing.   After entering the file search "Max_children" This is the number of php-cgi processes, a process accounted for 20m~30m memory, according to their own VPS or cloud host memory to calculate, like 512M memory, recommended set to 18;_terminate_timeout ", this is the time-out period, if the  php program to work long time, then set a larger time will be better, like set to 120 seconds, units default is the second, or write 120 the same can. Lnmpa encountered 504 Gateway time-out     When I followed the Nginx solution Setup, it was soon set to succeed, but the 504 gateway time-out would still appear, when I switched directly to the LNMP combination, Found no longer encountering the 504 Gateway time-out error, which indicates that the setting is already in effect, why is there such an error?   After a lot of data to find, and finally found that this is nginx and Apache communication time setup problem, when the user issued a PHP script execution request, Nginx will not execute PHP, will leave this issue to the backstage Apache,nginx will wait a while, Apache can process the PHP script request within the wait time, if not finished, Nginx has not received the data request to return the 504 Gateway time-out error, in fact, Apache will still be in the background processing PHP script, but the foreground returned error. The solution is to modify the Nginx and Apche communication time, in particular, the configuration proxy.conf, this file under/nginx/conf/, the name may change, like some installation package is laproxy.conf, anyway, is **proxy.conf file. Proxy_connect_timeout 60;  proxy_send_timeout 600;  proxy_read_timeout 90;  proxy_buffer_size 128k;proxy_buffers 8 128k;  proxy_busy_buffers_size 256k;  proxy_temp_file_write_size 100m;   The first item is the connection time, the front-end connection backend time, within 60s, the second is the sending time, allowing the back end of the time to return data, within 90s, the third time is read and write time, which is the front-end waiting for the backend processing time, which is leading to 504 Gateway Time-out root cause, this error occurred, indicating that the value is too small, recommended not less than 600s, the server is worse, then set longer, ensure processing is complete.   When I set this file up, restart Nginx and Apache, update the article again, no such error has been encountered, stating that the cause of the error is not nginX, but the communication time between the front and back ends is too short. In addition, Nginx will have 502 errors, in fact, the principle is similar, the same set of this part of the file, Lnmpa combination is still set the front and back of the communication time.

Lnmpa encountered a workaround for 504 Gateway time-out error

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.