PHP-FPM processes PHP files and works with Nginx to serve dynamic websites.
Install PHP-FPM
apt install php-fpm php-mysql php-curl php-xml php-mbstring php-zip -yConfigure Nginx for PHP
Add to your server block:
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.3-fpm.sock;
}Adjust the PHP version in the socket path to match your installed version.
Test
echo "<?php phpinfo();" > /var/www/html/info.php
nginx -t
systemctl reload nginxVisit http://YOUR_IP/info.php to verify. Delete the file after testing:
rm /var/www/html/info.php