Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Server \ LNMP summary of the issues common 502 Bad Gateway     - Linux / Unix desktops interesting: Christmas tree on the terminal (Linux)

- MySQL query optimization: profile function (Database)

- To install and deploy Apache under the CentOS (Server)

- Linux installed Cisco Packet Tracer (Linux)

- Android graphic introduction NDK installation and simple jni demo implementation (Linux)

- Management and application Oracle external table (Database)

- Using the Linux folder wc statistics number of lines of code for all files (including subdirectories) (Linux)

- When Linux virtual machine to another copy of the operating system, a static IP NAT mode Invalid (Linux)

- DBCA Error: ORA-19809: limit exceeded for recovery files process (Database)

- Ftp user to create multiple virtual machines to support different access rights Examples (Server)

- CentOS-based Kickstart automated installation practice (Linux)

- PHP file upload methods exist in the database (Programming)

- Linux C source code (sockettype: socket descriptor determination function) (Programming)

- Hibernate + JUnit test entity class generate database table (Programming)

- Fast Learning Clojure (Programming)

- PostgreSQL 9.3.2 Json type of use (Database)

- Kali Linux 2.0 U disk installation errors Your installation cd-rom could not be mounted (Linux)

- MySQL master-slave delay problem (Database)

- Linux common network tools: hping Advanced Host Scan (Linux)

- Timeout control related to Python threads and a simple application (Programming)

 
         
  LNMP summary of the issues common 502 Bad Gateway
     
  Add Date : 2018-11-21      
         
         
         
  When we configure LNMP, 502 always encounter problems, either in the browser or use the curl command to access, it is easy to appear the "502 Bad Gateway", then what reason is wrong, there is how to solve it . According to the author summed up the experience.

Error 1: Configuration Error

We first introduce LNMP environment, by definition, LNMP environment by nginx, mysql, php composition, but nginx belongs users and groups are php-fpm, then how will nginx with php link together? Here there are two modes, one is a socket mode, the other is a tcp / ip form (or called ip: port form).

When we configure nginx virtual host configuration file has this to say:

location ~ \ .php $ {

        include fastcgi_params;

        fastcgi_pass 127.0.0.1:9000;

        fastcgi_index index.php;

        fastcgi_param SCRIPT_FILENAME / data / www $ fastcgi_script_name;

}

Please note that this positive during the third row of the configuration file, I use here is ip: port of the form, what kind of when to use it? Should speak two can be. We generally default mode is the socket is connected via a socket file, and the default socket file directory is / tmp / directory, so the socket file path fastcgi_pass must write back right, otherwise there will be 502! !

If we do not generate not generated .socket files in the specified directory how to do it? This time we need to fastcgi_pass change ip: port form of attention if only to change the contents of this configuration file is still 502, we also need to change the contents of another configuration file that php configuration file: / usr / local / php / etc / php-fpm.conf, open the file we can see the following:

[Global]

pid = /usr/local/php/var/run/php-fpm.pid

error_log = /usr/local/php/var/log/php-fpm.log

[Www]

listen = 127.0.0.1:9000

user = php-fpm

group = php-fpm

listen.owner = nobody


listen.group = nobody


pm = dynamic

pm.max_children = 50

pm.start_servers = 20

pm.min_spare_servers = 5

pm.max_spare_servers = 35

pm.max_requests = 500

rlimit_files = 1024

The configuration file also listen to the same part of the ip: port form, so nginx and php to contact them, and then re

Loading nginx: /etc/init.d/nginx reload

The total sentence: in the form of these two places must be the same, or be wrong.

Error two: Permissions

We then start nginx, nginx can look at the process: ps aux | grep nginx

Then we discovered that the owner is a group of nginx worker processes are nobody

The 502 has been in order to solve problems caused wrong permission to do so, we need to profile /usr/local/php/etc/php-fpm.conf

Added two sentences:

listen.owner = nobody

listen.group = nobody

Then reload nginx

Error three: resource depletion

LNMP architecture processing php, nginx is a direct retrieval of backend php-fpm service, if the high volume of requests nginx, but we do not have enough to php-fpm configuration sub-process, then there is always a php-fpm resource depletion when, once you find the depletion nginx php-fpm, at this time will lead to 502 appear. Well, this time the solution is to adjust the value pm.max_children in php-fpm.conf to increase. But not an infinite set, after all, limited server resources, based on experience, 4G memory machine if only run php-fpm and nginx, do not run mysql service, pm.max_children can be set to 150, try not to exceed this value, 8G memory settings available 300, and so on.

Common mistake is above several, if not solve, refer to the error log, configuration files nginx.conf the error_log, adjust their level, will help us to see more mistakes.
     
         
         
         
  More:      
 
- Linux System Getting Started tutorial: Ubuntu desktop using the command line to change the system proxy settings (Linux)
- Android Touch message passing mechanism analysis (Programming)
- TPCC-MySQL Benchmark (Database)
- Linux 6 install Oracle 11g (64bit) (Database)
- Oracle ORA-01691 error message, a single data file size limit problem (Database)
- CentOS Linux build SVN server (Server)
- Using Libreoffice under ubuntu (Linux)
- How to deploy Python Web application: Heroku deployment process complete records (Server)
- KVM installation under CentOS 5.5 (Linux)
- Java Class file format parsing (Programming)
- Linux security concerns again (Linux)
- How to ensure that the Internet will not be attacked (Linux)
- C language binary tree counts words (Programming)
- Linux file time Comments ctime mtime atime (Linux)
- Mounting Windows shared directory system under the Linux (Linux)
- CentOS6 5 Configure SSH password Free (Linux)
- Use Ambari rapid deployment Hadoop big data environment (Server)
- MySQL 5.6 master-slave replication configuration (Database)
- stat Usage: Get permission to file the corresponding figures (Linux)
- ActiveMQ5.11.1 and JDK version matching relation (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.