Prerequisites
Shell access with sudo privileged account to Ubuntu 20.04 system.
Step 1 – Installing Nginx
Nginx packages are available under default repositories. SSH to your Ubuntu 20.04 LTS system with sudo privileges account and install Nginx web server from the official repository.
Step 2 – Installing PHP
For the PHP installation we recommend to use ppa:ondrej/php PPA, which provides latest PHP versions for Ubuntu systems. Use the below couple of commands to add the PPA to your system. Then install PHP 7.4 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 above packages php7.4-fpm service will automatically be started. You can make sure by typing below command on terminal.
Step 4 – Configuring NGINX with FPM
Next, create a Nginx server block configuration file to run PHP with FPM. Create and Edit a VirtualHost host configuration file in a text editor. You can create new VirtualHost as per your requirements, so make sure to enable any new VirtualHost. Use the below basic Nginx Virtual host configuration with php fpm settings. Update the configuration as followings.
Save your changes to the configuration file and create a link to site enabled directory. Then restart Nginx service to reload the changes.
Step 4 – Testing the Setup
Your server setup is completed now. Let’s create a PHP script with phpinfo() function and place it to your server document root. Use below command to create php script: Then access info.php viausing server IP address (for default VirtualHost) or configured domain in Nginx VirtualHost.
Slide down the page and see the value of $_SERVER[‘SERVER_SOFTWARE’]. This will the show the web server details.
Conclusion
In this tutorial, you have learned to configure Nginx web server with PHP-FPM on your Ubuntu 20.04 Linux system.
![How To Install Nginx with PHP FPM on Ubuntu 20 04 TecAdmin - 37](https://tecadmin.net/wp-content/uploads/2020/06/how-to-setup-nginx-php-fpm-ubuntu-20-04.png)