How To Install PHP for Nginx on Ubuntu 20.04 | Ubuntu 20.04 Nginx PHP
1.InstallPHPUnlikeApache,NginxdoesnotcontainnativePHPprocessing.ForthatwehavetoinstallPHP-FPM(FastCGIProcessManager).FPMisanalternativePHPFastCGIimplementationwithsomeadditionalfeaturesusefulforheavy-loadedsites.YoushouldaddUbuntu’suniverserepositorybeforeinstallingphp-fpmtoensureyougetthecorrectpackage.sudoadd-apt-repositoryuniverseNowupdatethepackagelistsandinstallPHP-FPMonUbuntu20.04.Wewillalsoinstallphp-mysqltoallowPHPtocommunicatewiththeMySQLdatabase.Press y and ENTER whenaskedtocontinu...
1. Install PHPUnlike Apache, Nginx does not contain native PHP processing. For that we have to install PHP-FPM (FastCGI Process Manager). FPM is an alternative PHP FastCGI implementation with some additional features useful for heavy-loaded sites.
You should add Ubuntu’s universe repository before installing php-fpm to ensure you get the correct package.
sudo add-apt-repository universeNow update the package lists and install PHP-FPM on Ubuntu 20.04. We will also install php-mysql to allow PHP to communicate with the MySQL database. Press y and ENTER when asked to continue.
sudo apt update && sudo apt install php-fpmIf you intend on using MySQL, you should also install the php-mysql package.
sudo apt install php-mysqlOnce installed, check the PHP version.
If PHP was installed correctly, you should see something similar to below.
PHP 7.4.3 (cli) (built: Mar 26 2020 20:24:23) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c)...