Home >Backend Development >PHP Problem >How to install php fpm
PHP FPM is a FastCGI process manager for PHP that can handle high-traffic websites and improve performance. In this article, we will show you how to install PHP FPM.
Installing PHP FPM
PHP FPM is shipped with PHP, so by default, no separate installation is required. However, if you are using Linux, you need to install the FPM package. To install run the following commands:
Debian/Ubuntu:
sudo apt-get install php-fpm
CentOS/RHEL:
sudo yum install php-fpm
Start PHP FPM
Once you have installed PHP FPM, you can start it using the following command:
sudo systemctl start php-fpm
You can check the status of FPM using the following command:
sudo systemctl status php-fpm
If FPM is running, you should see the message "active (running)".
Configuration PHP FPM
By default, PHP FPM uses the configuration file "/etc/php/fpm/php-fpm.conf". You can open the file with a text editor to make changes.
For example, you can change the following setting:
listen = /run/php/php7.4-fpm.sock
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
This configuration file configures PHP FPM to use Unix sockets for communication and sets max_children to 50 in order to handle more ask.
Related files:
Restart PHP FPM
The command to restart PHP FPM to apply configuration changes is as follows:
sudo systemctl restart php-fpm
Stop PHP FPM
To stop the PHP FPM service, run the following command:
sudo systemctl stop php-fpm
Summary
Leveraging PHP FPM can take the performance of your PHP applications to the next level. In this article, we show you how to install PHP FPM, and configure it to optimize performance.
The above is the detailed content of How to install php fpm. For more information, please follow other related articles on the PHP Chinese website!