: This article mainly introduces the Nginx + PHP-FPM optimization skills summary, for PHP tutorials interested in students can refer.
1. Socket communication in Unix domainBefore a brief introduction of Unix Domain Socket communication method, see: Nginx + PHP-FPM D
Preftest studio's new masterpiece-performance testing and tuning practices course video coming soon:
Http://www.hztraining.com/bbs/showtopic-617.aspx
At present, you have started to provide video tracking and purchasing for some chapters:
Http://www.china-pub.com/3501136
Http://www.hztraining.com/bbs/showtopic-617.aspx
The remaining chapters are being prepared! Stay tuned!
Attached course list:
reduces the memory overhead of the Web server while ensuring performance.
Advantages:1. compatible with most Web servers2. smaller memory than mod_php3. more configuration items, including PHP and suexecDisadvantages1. complicated configuration2. not well known
PHP-FPM (FastCGI Process Manager)
whether the PHP interpreter will be loaded into memory, typically processing CSS, JS and other static files is absolutely no need to load the interpreter.
2. Number of requests processed by a single process
Mod_php and fast-cgi are capable of processing multiple requests during the lifetime of each process, while CGI mode processes a request to destroy the process immediately, and CGI performance is ver
The way to resolve 502 Bad Gateway is:
1. Depending on the performance of the server, in the php-fmp.conf to increase the value of Max_children, I currently use 15.
(a php-fpm uses about 20M of RAM, if your memory is about 1G,1024/20=50)
2. Use the reload parameter to reload the
Use unixsocket or TCP for communication between nginx and php-fpm and Its Configuration
Preface
Nginx and fastcgi can communicate in either TCP or unix socke. The two methods have their own advantages and disadvantages. Here we first provide two configuration methods, and then summarize the performance and security.
TCP is to use TCP port to connect 127.0.0.1: 90
Mod_php, FastCGI, PHP-FPM and other PHP Running Mode Comparison, mod_phpfastcgi
Overview
I wrote this article because I want to build the LNMP environment under Ubuntu today, Nginx uses a PHP-FPM, so the interaction between the Web server and the
systemBottom-level difference: OS differentVirtual Machine There are many languages that can develop web programs, but some programs are more suitable for developing Web applications. Programming languages static languages: Compiled languages ---> are strongly typed, only compile before running cc++java Advantages: High efficiency, good performance Cons: Every change must be recompiled, long development cycle, maintenance costs. Dynamic l
Cgi
CGI, Common Gateway Interface, is a tool for HTTP Server-to-contact with programs in other servers, which can used into any languages with standard input, standard output and environmental variables, such as PHP, Perl, or TCL.
FastCGI
FastCGI is a kind of the CGI which is long-live, which'll always be running. With FastCGI, it's ll take less time T fork(which is a problem of Fork-and-execute mode in CGI). In additional, FastCGI a
, resulting in low performance.
2. FASTCGI is the resident memory CGI. It is actually the Process Management of the CGI program. It accepts requests through the master process and distributes the requests to the worker process. It can also prefork worker processes, reduces the overhead of CGI process creation, initialization, and destruction to improve performance.
3. mod_php is the built-in
Problem: Because the xdebug extension is enabled, the prompt "{code...}" appears when you use composer ...} so I want to stop loading the xdebug environment under cli: linux is installed for archlinuxphp through pacman, and version 7.0.1web service runs the configuration file distribution through php-fpm: {generation... problem:
When composer is used, the following message is displayed:
You are running comp
-cgi re-spawn times and improve the overall performance. In our actual production environment, we found that the memory leakage was not obvious, so we set this value to a very large value (204800 ). You must set this value based on your actual situation and do not blindly increase it.In other words, the purpose of this mechanism is to ensure that php-cgi only occupies memory in different places. why not use
Overview
Writing this article is because today to build the LNMP environment Ubuntu, Nginx use is PHP-FPM, so the Web server and the PHP interpreter interactive way to do a collation.
As we all know, PHP is a cross-platform, Cross-platform language, which is one of the reasons why it is so popular. However, few peopl
improving security;2nd, if [www] This pool request volume is too big, down, the process is not enough, if all use a pool, a website hangs off, then other websites also hang off, will be implicated.So the benefit of this partitioning is that multiple sites can be prevented from having problems at the same time.We can also do some performance-tracking operations in the PHP-
CGI programs, accepting requests through the master process, distributing them to worker processes, and prefork worker processes, reducing the overhead of CGI process creation, initialization, and destruction, thereby improving performance.3. mod_phpMod_php is Apache's built-in PHP interpretation module, using Prefork way, do not need additional process to do communication and application interpretation, o
do it in three steps.
Step 1, Edit/etc/nginx/conf. d/your site configuration file (if the default configuration file is used, modify/etc/nginx/sites-available/default)
Change the fastcgi_pass parameter to 127.0.0.1: 9000, as shown in the following figure:
location ~ \.php$ { index index.php index.html index.htm; include /etc/nginx/fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi_params;?}
Nginx parses the principles of PHP, cgi/fastcgi and php-fpm relationships.First, the scene that Php+nginx came into being.With the development of the Internet, the user accepts a wide range of this, the increase in data flow makes the web end of the running load pressure increasing, savage growth in the big Data era of
faster CGI. it allows multiple requests to be processed in a process, rather than directly ending the process after a request is processed, which greatly improves the performance.
As for FPM (FastCGI Process Manager), it is the implementation of FastCGI, and any Web Server that implements the FastCGI protocol can communicate with it. FPM also provides some enha
configuration and expansion, initialize the execution environment, the performance is very poor, all have the following process:
So the implementation of Fastcgi protocol programs, such as PHP-FPM is how to do it? First, Fastcgi will start a master process, parse the configuration file, initialize the execution environment, and then start multiple worker proces
is rammed. This is the above-mentioned fate parameters, set up the Oomkill, but also to ensure that the service can only introduce the Guardian. } }group THIRTY{cpu{ cpu.shares=3000;} memory{memory.soft_limit_in_bytes=5g; memory.limit_in_bytes=10G; memory.swappiness=0; memory.oom_control=0; } }group ten{cpu{ cpu.shares=1000;} memory{ memory.soft_limit_in_bytes=1g; memory.limit_in_bytes=2G; memory.swappiness=0; memory.oom_control=0; } }Supervistor configuration:/etc/supervisord.d/
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.