How to install PHP-FPM on Ubuntu

  • avatar
  • 6.9K Views
  • 4 mins read

By default Nginx is not capable of processing dynamic web pages with PHP so it requires the use of specific additional plugins for this purpose. One of these plugins is FPM (FastCGI Process Manager).  FPM is an alternative PHP FastCGI implementation with some additional features (mostly) useful for heavy-loaded sites. It is the preferred method of processing PHP pages with Nginx and is faster than traditional CGI based methods.

Prerequisites

Before installing PHP-FPM you will need a working NGINX setup. If you do not already have it you can take a look to our Nginx installation and configuration tutorial.

Installing PHP-FPM

PHP-FPM is available and can be installed using the apt packaging system:

sudo apt-get update && sudo apt-get install php7.4-fpm

The above command will download and install all of the necessary dependencies. Once PHP-FPM is installed, you can check the successful PHP installation with the command:

php -v

The output will show the installed version of PHP:

php_version.png

Configuring Nginx

Now that you have PHP-FPM installed, you will need to update the Nginx configuration file (with nano or any other editor):

sudo nano /etc/nginx/sites-available/default

Uncomment the following lines for PHP-FPM to run on our server:

nginx_php_fpm.png

Don't forget to add the index.php to the indexes list:

nginx_php_index.png

Save the configuration file and restart Nginx server to apply the changes:

sudo systemctl restart nginx.service

We have successfully configured our Nginx server with PHP-FPM. We can now host our website.

 Join Our Monthly Newsletter

Get the latest news and popular articles to your inbox every month

We never send SPAM nor unsolicited emails

0 Comments

Leave a Reply

Your email address will not be published.

Replying to the message: View original

Hey visitor! Unlock access to featured articles, remove ads and much more - it's free.