Current Location: Home> Latest Articles> Complete Guide to Installing and Configuring PHP-FPM on CentOS 7

Complete Guide to Installing and Configuring PHP-FPM on CentOS 7

gitbox 2025-06-27

Preparing to Install PHP-FPM on CentOS 7

PHP is a widely used server-side scripting language in modern web development, and PHP-FPM (FastCGI Process Manager) significantly enhances PHP performance. This tutorial walks you through the correct steps to install and configure PHP-FPM on CentOS 7.

Update the System

Start by making sure your system packages are up to date. Run the following command in your terminal:

sudo yum update -y

Install EPEL and Remi Repositories

PHP-FPM isn't included in the default CentOS repositories. Install EPEL and Remi repositories first:

sudo yum install epel-release -y
sudo yum install https://rpms.remirepo.net/enterprise/remi-release-7.rpm -y

Enable Remi Repository for PHP 7.4

After installing the repositories, enable the PHP 7.4 Remi repo (or another version if needed):

sudo yum-config-manager --enable remi-php74

You can also enable other versions like remi-php80 or remi-php81 depending on your project requirements.

Install PHP and PHP-FPM

Once the repo is enabled, install PHP and the PHP-FPM package using:

sudo yum install php php-fpm -y

Configure PHP-FPM

After installation, you need to configure PHP-FPM. Edit its main configuration file:

sudo vi /etc/php-fpm.d/www.conf

Locate the following lines and change the values to match your web server user (e.g., nginx):

user = nginx
group = nginx

Start and Enable PHP-FPM Service

Now start the PHP-FPM service and enable it to launch on boot:

sudo systemctl start php-fpm
sudo systemctl enable php-fpm

Check PHP-FPM Service Status

Verify that PHP-FPM is running correctly with the following command:

sudo systemctl status php-fpm

If the status shows active (running), the service has started successfully.

Conclusion

With this guide, you've successfully installed and configured PHP-FPM on CentOS 7. PHP-FPM provides efficient process management and can significantly improve the performance of PHP applications. It's an essential component for building fast and reliable production environments.