You can also visit the previous tutorial to configure Apache with multiple PHP versions using PHP-FPM/FastCGI on Ubuntu systems.

Step 1 – Installing Apache

Apache web server debian packages are available under the default repositories. Login to your Ubuntu system with sudo privileges account. Open a terminal and execute the following commands: The above commands will install Apache and FastCGI module to your server.

Step 2 – Install PHP with FPM

Next, install PHP and PHP-FPM on your Ubuntu system. For this tutorial, we choose PHP 7.4 to install using For the PHP installation we recommend to use ppa:ondrej/php PPA. Execute below couple of commands to add the PPA to your system. Then install PHP 7.4 (or required version) the latest version available on the day of writing this tutorial. Simply execute follows commands for the installation of PHP and PHP-FPM packages. After installing the packages php7.4-fpm service will automatically be started. To make sure, type:

Step 3 – Apache Configuration

Now, You need to enable some of the Apache modules required for the FastCGI confiugration. You can enable the requird module by running command: Then configure Apache Virtual Host to run with FPM/FastCGI. For this tutorial, we use default VirtualHost. Edit VirtualHost host configuration file in a text editor. You can also create a new configuration as per your choice. Update the configuration as followings.

Save your changes to the configuration file and restart Apache to reload the changes.

Step 4 – Verify Setup

Apache with PHP-FPM configuration has been done. Now all the PHP files will be run with the FPM. To verify these settigns, create a PHP script with phpinfo() function and place it to your server document root. Use below command to create file: Then access the info.php using server IP address (for default VirtualHost) or your configured domain in Apache VirtualHost.

Conclusion

This tutorial helps you to install Apache with PHP-FPM on Ubuntu system.

How To Install Apache PHP FPM on Ubuntu 20 04   TecAdmin - 14