Modern programming is a distributed processing of growing volumes of information. Local tools in the distant past. Web servers, distributed teams of developers and consumers are relevant. Tasks and applications have turned into query flows that require instant responses.
Php is a popular programming language, but it "flows" on its own initiative and provides fertile ground for qualified developers to create tons of inefficient code. A novice programmer is more promising than an ace of computer technology on the simple basis that relates to the work carefully, carefully and diligently solves the problem with a minimum amount of code.
Reasons for the idea and idea of fpm
There is no need to “plow” tons of code from eminent predecessors to the solution of the problem, just write beautiful and well-commented code. But it is precisely the large code, the popular web resources, the technological flaws of Php, and the increase in the load (visitors) on web resources that owe their birth to the numerous options for speeding up the processing of requests to web servers.
A regular server takes all the burden on itself, paints it according to processes and ingenious logics. His capacity is limited, and he is forced to queue new requests until he can cope with those that are already at work.
Various versions of SAPI (Server API) to one degree or another solved the problem of quick processing of the request flow, but restrictions remained. The appearance of Nginx introduced the web resource as a combination of statics and dynamics, and transferred the work of hosting maintenance into the realm of events and load management.
There are not so many Php on the web page, but there is always a lot of text, pictures and other elements that can be safely sent to the visitor’s browser immediately, without processing by any server process. Only when there is Php code on the page, should you use Php or Php-fpm.
In essence, this is a fast process manager (FastCGI Process Manager). And it can be run many times, but only if it is reasonably necessary. Each request will have its own process. The next request is the next process. This significantly changes the situation, and the page of the site in full will quickly appear in the browser of the visitor.
This is not to say that the idea of Nginx and Php-fpm is the cure for all problems, but in many cases it is a great solution for creating a productive web server. You can go even further by combining Apache's experience and wisdom with the youth and ambitiousness of Nginx. In this case, bulky processes can be sent to Apache, and light pages to Php-fpm.
Assessment and preparation
The whole Linux family is distinguished by simplicity and convenience. In fact, the administration of these systems requires knowledge and skills. The UBUNTU system under Php-fpm and Nginx is a good choice. Enterprise-CentOS will require more knowledge.
The rest of Linux is less popular, although in each case, you should carefully evaluate all the circumstances and make an informed decision.
For example, a domestic RUNTU, which few people know about, can quickly save the situation when you need to install the system in a virtual container with limited space inside the local network and other inconveniences.
It’s not enough to put Php-fpm, it must also be checked before “going out”. RUNTU is an ideal tester when only a configurable computer (its virtual container) looks into the outside world. In the local network, you can always quickly establish a peaceful contact. You can check not only Php-fpm: setting up and checking multiple Nginx virtual hosts will also be available.
It is always best to start by installing the system. In cases where the system is already installed and you need to install only Php-fpm, unforeseen problems may arise. For example, in CentOS 6 and Php 5 limitation. In CentOS 7 and Apache + Php 7.
Fashion for virtual machines is also a limitation. Freshly baked and promising “Space Cuttlefish” (Ubuntu 18.10 Cosmic Cuttlefish) can easily stand in a virtual container, but will not work in principle. It looks like a declaration: my environment is outer space, and not some kind of container there.
Linux is not Windows, but it can and can do it at any opportunity. Only knowledge and skills help to cope with the task in any operating environment.
Install UBUNTU
Installing UBUNTU 18.04 in server version is a simple and practical solution.
Fast, easy and practical. A good reason that any Linux appropriately refers to is practice. Even if you need to install php-fpm on CentOS 6, it does not hurt to pass the test on a reliable and simple system. It will be easier to understand where and what to look for in the system to which the task is oriented.
Nginx installation
Just one team and a few minutes. A modern and fast web server has become a machine or container. You just need to open the ports in the firewall and you can move on.
The main Nginx configuration is located at:
and you should always remember three commands:
- systemctl status nginx;
- systemctl stop nginx;
- systemctl start nginx.
They should be used for any changes to the server configuration. We should not forget that the configuration change, registration of virtual hosts is associated with IP addresses and host names, which should also be taken into account in the hosts file located at:
It doesn’t matter when to install Php-fpm, Php, MySQL, Apache and Nginx, but it’s wiser to start from the last two positions, and then move on to the other.
Setting up a quick manager
Installing php-fpm is one command and two actions.
Installation is performed, the semicolon (comment symbol) in the php.ini file is removed, and the manager is restarted.
It is important to pay attention: the link to the quick manager is a site configuration file. In this case, the server has only the source site and its configuration in the default file.
For each virtual host, it will be necessary to make appropriate changes in its configuration file in the server block.
Three location blocks are highlighted in the figure: the first one was already there, the next two are added. The first concerns everything, the second only Php files, the third makes a ban on .ht * files - this refers to Apache configuration files.
Testing the work done
In the root folder of the site, create the index.php file and test the Nginx configuration. There will be no problems if everything is done neatly and correctly.
Then you can restart the web server and get the desired result.
In the given example, Php-fpm 7.2 became the automaton. In each case, there may be other options. Often used Php 5 and its corresponding fast manager.
Technological details
Php is a popular and used language. It’s not at all annoying that between the 5th and 7th versions the 6th version has gone somewhere. You may not recall that Php 5.2. * And 5.6. * Are "different" products.
Like any other language, the Php interpreter suffers from memory leaks. Programmers are used to memory loss, especially when it comes to recursion, stack, and other "uncontrolled" sections of code. After the execution of a critical section of code, it became the norm to destroy everything that was connected with it.
Another is problematic and critical. With the advent of site management systems (CMS), it has become customary to drive tons of useless (i.e. not displayed) code from the server into the bowels of the browser, and they are not unlimited. Communication channels are good, but they feel much calmer when only the necessary information moves through them.
It is very good that now there is Php-fpm. You can effectively manipulate the load, separate the statics from the dynamics. But it is much better when the developer creates a web resource with the least possible and high-quality code.
Modern technologies are good only when they are used in the volume and quality, when they are effective, compact and practical.