Install Php-fpm 7.4

0 views
Skip to first unread message

Heike Fallago

unread,
Aug 3, 2024, 1:05:58 PM8/3/24
to doungeluabra

The PHP-FPM's homepage -fpm.org/ states that it is part of PHP since PHP 5.3.3. Now, I was wondering, when I download the newest PHP binaries from php.net, there is no php-fpm in it. How do I get it? Is it even available for Windows?

Download the .zip file from The .zip file should be VC9 which has the FastCGI file (php-cgi.exe). Don't download VC6, and don't download the .msi file because it requires that you have IIS setup already in order to install php-fpm. The zip file contains the php-cgi.exe which is what you need for php-fpm. I downloaded a slightly older version, php-5.3.10-Win32-VC9-x86.zip, from here because I wanted to match the version running on my production server.

Yes PHP-FPM stands for PHP-FastCGI Process Manager and so implements FastCGI but you are forgetting that FPM is much more than that as it contains process management features that are not managed by the webserver.

On *nix systems PHP-FPM has a separate process that manages the PHP child processes and has a detailed configuration to specify how these processes are managed. For details on these features read here

Note, this is based on a post in Apache Lounge. As helpful as it was, their version had quotes around c:/php/php-cgi.exe and if you do that it WILL NOT START php-cgi.exe, at least on Windows Server 2012, and you get HTTP 500. Took me a painful few days to figure that out.

Starting PHP v5.3.3, FPM Server-API [SAPI] support has been integrated into core PHP. This means, you can take PHP's source codes and compile and build them with FPM-SAPI [using --enable-fpm configuration parameter] support, instead of let's say Apache SAPI [--enable-apx2]. As shown in PHP-Wiki you can build PHP almost the same way you do in *nix systems - that is, configuration-wise. I would suggest you learn the ins and outs of building PHP in *nix systems first, and even try to do it yourself [usual configure, make and make install pattern], and then try to utilize the experience gained from it to build on Windows environment.

In addition to --enable-fpm configuration parameter, there are two additional parameters as well: --with-fpm-user=USERNAME_HERE and --with-fpm-group=USERGROUPNAME_HERE. These two work in *nix environment, but may not be available in Windows.

EDIT 1: Ok, guess I might be wrong re the possibility of building PHP-FPM on Windows, since this SAPI uses libevent component from *nix environment. Guess you will have to stick with Cygwin-bundled installation after all.

On Windows, when you run PHP with IIS and install the "PHP FastCGI" module, you get similar functionality to what is explained about PHP-FPM. In other words, this is not the official PHP-FPM code base, but just similar functionality.

For one, IIS would spawn multiple php-cgi.exe processes (worker processes). And any PHP requests that come in will be handed down to a worker, IIS will dynamically spawn more workers depending on the server resources. These settings are configurable under the "Fast CGI" options for the server tree node on IIS.

FastCGI addresses the performance issues that are inherent in CGI by providing a mechanism to reuse a single process over and over again for many requests. Additionally, FastCGI maintains compatibility with non-thread-safe libraries by providing a pool of reusable processes and ensuring that each process handles only one request at a time.

PHP-FPM uses mainly *NIX specific features and is not likely to ever be ported to Windows. In the end there really isn't the motivation, especially when considering php-cgi was developed to allow Windows specific services to configure it as a fork pool. Yes, they have their differences, but not enough so to push the community into a complete rewrite of PHP-FPM.

Keep in mind that php-cgi on Windows is not just multiple instances of a CGI, but uses a Windows managed pool of forked FastCGI processors which use the same architecture of PHP-FPM. Multiple processes complete the module initialization of PHP, and from these multiple forks are maintained (and restarted when needed) to handle requests. php-cgi hasn't been a CGI since at least as early as PHP3.

A common mistake is to install the PHP, not PHP-FPM package. The problem with this approach is that unlike PHP-FPM, the PHP package installs the Apache HTTP server and its httpd process, which conflicts with Nginx.

A simple PHP install uses the libapache2-mod-php module by default, which requires installation of the full Apache HTTP server software suite. To avoid this, install either the php-cgi or the php-fpm module for Nginx.

With the configuration of Nginx, PHP and the PHP-FPM module complete, and a new file named info.php added to the web server, simply open a browser to to test the setup. The PHP info page, attesting to the fact that the install on Nginx of PHP 8.1, will appear.

PHP-FPM (FastCGI Process Manager) is an alternative to FastCGI implementation of PHP with some additional features useful for sites with high traffic. It is the preferred method of processing PHP pages with NGINX and is faster than traditional CGI based methods such as SUPHP or mod_php for running a PHP script. The main advantage of using PHP-FPM is that it uses a considerable amount of less memory and CPU as compared with any other methods of running PHP. The primary reason is that it demonizes PHP, thereby transforming it to a background process while providing a CLI script for managing PHP request.

Also, the process managers settings in the above pool configuration file are set to dynamic. Choose a setting that best suits your requirement. The other configuration options for process manager are:- Static: A fixed number of PHP processes will be maintained.

The FPM pool will be created immediately to serve php pages. Remember, you can create a separate systemd service by specifying the above FPM configuration file thereby enabling you to start/stop this pool without affecting other pools.

To test if the above NGINX configuration file is indeed using the newly created FPM pool, create a php info file inside the web root. I have used /var/www/html/wordpress as a web root in the above NGINX configuration file. Adjust this value according to your environment.

Once you are done with creating the PHP info page, point your favorite web browser to it. You will notice that the value of $_SERVER['USER'] and $_SERVER['HOME'] variable are pointing to wordpress_user and /home/wordpress_user respectively that we set in the FPM configuration file previously and thus confirms that the NGINX is serving the php pages using our desired FPM pool.

In this article, we learned how to install php-fpm and configure separate pools for different users and applications. We also learned how to configure an NGINX server block to connect to a PHP-FPM service. PHP-FPM provides reliability, security, scalability, and speed along with a lot of performance tuning options. You can now split the default PHP-FPM pool into multiple resource pools to serve different applications. This will not only enhance your server security but also enable you to allocate server resources optimally!

While we believe that this content benefits our community, we have not yet thoroughly reviewed it. If you have any suggestions for improvements, please let us know by clicking the report an issue button at the bottom of the tutorial.

Currently, I get 503 errors. However, if I drop my own script in there (like a php script that just echos hello), I can get the script to work. But any of the Nextcloud files will result in a 503 WSOD

Hmmmm well, not sure what piece of the puzzle caused my issues, but CalDAV completely stopped working after switching to an Apache + PHP-FPM + HTTP2 server in general, reverted back to original everything for now

Do you have any other suggestion about what should be changed about Apache2 (not PHP/FPM) settings/setup, besides the SetHandler above?
So far at least the switch is easy, compared to other solutions with libapache2-mod-fcgid and more complex looking implementation.

Okay, but your enabled Apache modules already look fine. If the apache.conf points to the correct php-fpm socket, and as well according to the error message, it could be due to missing PHP modules or at wrong version, e.g.:

There is no .htaccess equivalent for Nginx, if this was the question. .user.ini can be used to set certain PHP settings and all webserver settings need to be placed in the Nginx config, e.g. inside the ^/nextcloud location directive to apply directory-wise.

Before we can start building our world-changing website or application on LEMP, we have to lay the foundation for the stack. In this hands-on lab, we will walk through installing and configuring PHP-FPM on Ubuntu Linux.When the lab is complete, we will have a configured PHP-FPM installation on Ubuntu Linux.

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Since each PHP version can have different base image, the required libraries can be different too. If it is the case, you need to try to install the extension, read the error messages and install the libraries mentioned by the error message. Sometimes it is not obvious, but if you want to work with PHP, especially in a container, you need to understand Linux a little more than otherwise. It was a long procesdure for me too.

Yes, your two quoated outpus are the same but both of them different from the original output you shared. This is exactly the output I thought you have. It means the new PHP 8 does not have those options that PHP 7 had.

You can check the rest of the extensions the same way you did with opcache. Of course an extension to be loaded does not always mean it works properly. So if you want to make sure, you have to test it.

c80f0f1006
Reply all
Reply to author
Forward
0 new messages