What to do if php-cgi stops under Linux
The solution to php-cgi stopping under Linux is: change the nginx configuration item, reduce the number of FastCGI requests, and try to keep the buffers unchanged, such as [fastcgi_buffer_size 128k;].
#The operating environment of this article: linux 5.9.8, php 7, thinkpad t480 computer.
Foreword:
I accidentally discovered that a server in production (centos 5.2 64-bit 4G memory) always had the problem that the website could not be opened. Later, I went to the server to check and found that both nginx and php-cgi were running, but the cpu usage of php-cgi was 0 at this time. So I immediately checked the file handle limit:
ulimit -n
The result was: 1024, which is too small for services in production.
Most of the solutions given on the Internet are to directly enter
ulimit -SHn 51200 # 51200可自己根据应用调整
The disadvantage of this method is obvious. Once you log out, the settings will become invalid.
It is also said that the command should be written directly to /etc/rc.d/rc.local. Today I found a correct way.
Open /etc/security/limits.conf, inside There are very detailed comments. Find the following settings (insert if not)
The code is as follows
* soft nofile 51200 * hard nofile 51200
Log in again after exiting and check the number of handles. It has been correctly set to 51200.
If you encounter a similar situation, you can check to see if the number of file handles is set too small.
Solution to 502 Bad Gateway when accessing
Nginx 502 Bad Gateway means that the requested php-cgi has been executed, but for some reason (usually a problem with reading resources) The execution is not completed and the php-cgi process is terminated. Generally, websites with too high concurrency are prone to this error. There are many reasons why 502 Bad Gateway appears, but most people can solve it by modifying the parameters below.
Change several configuration items of nginx, reduce the number of FastCGI requests, and try to keep the buffers unchanged:
The code is as follows
fastcgi_buffer_size 128k; fastcgi_buffers 2 256k; fastcgi_busy_buffers_size 256k; fastcgi_temp_file_write_size 256k;
Open /usr/local/php/etc /php-fpm.conf file, modify the following parameters:
The code is as follows
25 requests">2048 65535 30s 60s
request_terminate_timeout refers to the execution script time of fast-cgi, which defaults to 0s. The meaning of 0s is to let php-cgi continue to execute without time limit. If you set it to 0s here, then when a 502 Bad Gateway appears, the 502 status will continue and will not change. But if you set it to 5s, then php-cgi will automatically recover after 5s. This value can be set according to the performance of your server. Here I set it to 60s.
max_children represents the processing process of php-cgi. If max_children is set to a smaller value, such as 5-10, then php-cgi will be "very tired", the processing speed will be very slow, and the waiting time will be longer. If a request is not processed for a long time, a 504 Gateway Time-out error will occur. Setting max_children also needs to be set according to the performance of the server. As the number of processes increases, the memory usage will increase accordingly. Under normal circumstances, the memory consumed by each php-cgi is about 20M. Here I set it to 25.
The default static processing method of php-fpm will cause the php-cgi process to occupy memory for a long time and cannot be released. This is also one of the reasons for nginx errors, so you can change the processing method of php-fpm to apache -like mode.
After the modification is completed, execute lu-restart (LuManager server management system).
Recommended learning: php training
The above is the detailed content of What to do if php-cgi stops under Linux. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Using python in Linux terminal...

Multithreading in the language can greatly improve program efficiency. There are four main ways to implement multithreading in C language: Create independent processes: Create multiple independently running processes, each process has its own memory space. Pseudo-multithreading: Create multiple execution streams in a process that share the same memory space and execute alternately. Multi-threaded library: Use multi-threaded libraries such as pthreads to create and manage threads, providing rich thread operation functions. Coroutine: A lightweight multi-threaded implementation that divides tasks into small subtasks and executes them in turn.

To open a web.xml file, you can use the following methods: Use a text editor (such as Notepad or TextEdit) to edit commands using an integrated development environment (such as Eclipse or NetBeans) (Windows: notepad web.xml; Mac/Linux: open -a TextEdit web.xml)

Regarding the problem of removing the Python interpreter that comes with Linux systems, many Linux distributions will preinstall the Python interpreter when installed, and it does not use the package manager...

Linux is best used as server management, embedded systems and desktop environments. 1) In server management, Linux is used to host websites, databases, and applications, providing stability and reliability. 2) In embedded systems, Linux is widely used in smart home and automotive electronic systems because of its flexibility and stability. 3) In the desktop environment, Linux provides rich applications and efficient performance.

DebianLinux is known for its stability and security and is widely used in server, development and desktop environments. While there is currently a lack of official instructions on direct compatibility with Debian and Hadoop, this article will guide you on how to deploy Hadoop on your Debian system. Debian system requirements: Before starting Hadoop configuration, please make sure that your Debian system meets the minimum operating requirements of Hadoop, which includes installing the necessary Java Runtime Environment (JRE) and Hadoop packages. Hadoop deployment steps: Download and unzip Hadoop: Download the Hadoop version you need from the official ApacheHadoop website and solve it

"DebianStrings" is not a standard term, and its specific meaning is still unclear. This article cannot directly comment on its browser compatibility. However, if "DebianStrings" refers to a web application running on a Debian system, its browser compatibility depends on the technical architecture of the application itself. Most modern web applications are committed to cross-browser compatibility. This relies on following web standards and using well-compatible front-end technologies (such as HTML, CSS, JavaScript) and back-end technologies (such as PHP, Python, Node.js, etc.). To ensure that the application is compatible with multiple browsers, developers often need to conduct cross-browser testing and use responsiveness

Do I need to install an Oracle client when connecting to an Oracle database using Go? When developing in Go, connecting to Oracle databases is a common requirement...
