Dump the code
Best ressources to improve your Python Skills

Installing PHP-FPM

Created 10 months ago
Posted By admin
3min read
To install PHP-FPM on Debian using the package manager apt, you can follow these steps. PHP-FPM is often used in conjunction with Nginx or Apache, so you may want to install a web server as well.

1. Update ackage list:

sudo apt update

2. Install PHP and PHP-FPM:

sudo apt install php-fpm

3. Start and enable PHP-FPM service:

sudo systemctl start php8.2-fpm   # Adjust the version number based on your PHP version
sudo systemctl enable php8.2-fpm  # Enable auto-start on boot
adjust the version number based on your PHP version.

4. Test PHP-FPM:
T
o check the status of the PHP FPM, you can use this command

sudo systemctl status php8.2-fpm

5. Configure PHP-FPM:
php.ini
and php-fpm.conf are two distinct configuration files used in the PHP ecosystem, but they serve different purposes.

php.ini is the main configuration file for PHP itself. It contains various settings that control the behavior of the PHP interpreter, such as memory limits, error reporting, and other runtime configurations.
It is a global configuration file and affects all PHP scripts running on the server.

php-fpm.conf is the configuration file for PHP-FPM (FastCGI Process Manager). PHP-FPM is a separate process manager that works in conjunction with web servers (like Nginx or Apache) to handle PHP requests.
It is specific to PHP-FPM and defines settings related to the management of PHP processes, pools, and how they interact with the web server.

php.ini is concerned with configuring the runtime behavior of the PHP interpreter itself, while php-fpm.conf deals with the configuration of the PHP-FPM process manager, which manages and processes PHP requests in a web server environment. They work together to ensure the proper functioning of PHP applications within a web server architecture.
Both configuration files are located in the /etc/php/8.2/fpm/ directory.

Modify theses files according to your requirements, and be sure to restart PHP-FPM once you've completed the changes.

sudo systemctl restart php8.2-fpm
 
6. Starting and stopping PHP-FPM:
Starting and stopping PHP-FPM, as well as performing graceful restarts, can be accomplished using service commands or directly through the systemd service management tool. Below are examples of how you can manage PHP-FPM using service commands and perform a graceful restart.

sudo systemctl start php8.2-fpm  # start PHP-FPM
sudo systemctl stop php8.2-fpm # stop PHP-FPM
sudo systemctl restart php8.2-fpm # restart PHP-FPM

7. Graceful Restarts:
A graceful restart allows PHP-FPM to reload its configuration and worker processes without interrupting the existing connections. It's a more controlled way to apply changes.

sudo php-fpm8.2 -t  # Check PHP-FPM Configuration for Syntax Errors
sudo service php8.2-fpm reload  # Perform a Graceful Restart
Alternatively, you can use the following command to send a SIGUSR2 signal directly to the PHP-FPM master process:

sudo kill -USR2 $(pidof php-fpm8.2)  # Adjust the version number
This graceful restart allows PHP-FPM to re-read its configuration and smoothly restart worker processes.
Topics

Mastering Nginx

27 articles

Bash script

2 articles

Crontab

2 articles