Possible causes and solutions for nginx 502 Bad Gateway error in the one-click lnmp installation package

Source: Internet
Author: User
The first reason is that the lnmp one-click installation package has many problems, namely 502 Bad Gateway. In most cases, some lib packages in the script may not be installed before PHP is installed, as a result, PHP is not compiled and installed successfully. Check whether/usr/local/PHP/sbin/PHP-FPM exists.
Solution:
You can try to manually install the lnmp installation package according to the script in the one-click installation package to see what caused the error. Search for it online or send the error message. If the lnmp.loglog file at http://lnmp.org/install.htmlis not provided (you can use winscp to log on and download lnmp. Log, compress it, and upload it to this forum), there is no error message to say why.

The second reason is:
In PHP. ini, The eaccelerator configuration item must be placed before Zend optimizer configuration; otherwise, it may cause 502 Bad Gateway

The third reason is:
502 problems occur during installation and use. Generally, the default PHP-CGI process is five, which may be caused by insufficient phpcgi processes, you need to modify/usr/local/PHP/etc/php-fpm.conf to add the max_children value as appropriate.
It is also possible that the max_requests value is insufficient.

The fourth reason is:
PHP Execution time-out. Modify/usr/local/PHP/etc/PHP. ini and change max_execution_time to 300.

Fifth reason:
Insufficient disk space. For example, MySQL logs occupy a large amount of space to clean up files on the disk. If there is some space left, restart and restore the disk.

Sixth reason:
Check whether the PHP-CGI process is running

7 Reasons:
In nginx. conf
Fastcgi_connect_timeout
Fastcgi_send_timeout
The value of fastcgi_read_timeout is greater.

Eighth possible cause: http://bbs.vpser.net/thread-1654-1-1.html

9. You can also try to change the UNIX socket to TCP/IP, modify/usr/local/PHP/etc/php-fpm.cnf to set <value name = "listen_address">/tmp/nginx. socket </value> is changed to <value name = "listen_address"> 127.0.0.1: 9000 </value>, and/usr/local/nginx/CONF/nginx. conf and its/usr/local/nginx/CONF/vhost/fastcgi_pass Unix:/tmp/php-cgi.sock in the virtual host configuration;
Replace it with fastcgi_pass 127.0.0.1: 9000. Then restart and try again.

10. If the log file of the VM is too large, it may cause 502 problems.
We recommend that you regularly clear the log files of the VM.

11. SomeProgramOr the theme of the program has an endless loop or other resources that are very resource-consuming.CodeIt may also cause 502. You can try to temporarily comment out the possible host configuration file and restart it to see if it will return 502.

12, if the above methods have been tried, but sometimes there will be 502 error, you can try to add 502 Automatic Restart Script: http://bbs.vpser.net/thread-1913-1-1.html

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.