PHP is one of the most used server-side programming languages. Many popular CMS and frameworks such as WordPress, Magento, and Laravel are written in PHP.
This guide covers the steps necessary to install PHP on Ubuntu 20.04 and integrate it with Nginx and Apache.
At the time of writing, the default Ubuntu 20.04 repositories include PHP 7.4 version. We’ll also show you how to install previous PHP versions. Before choosing which version of PHP to install, make sure that your applications support it.
If you’re using Apache as your web server, run the following commands to install PHP and Apache PHP module:
sudo apt update
sudo apt install php libapache2-mod-php
Once the packages are installed, restart Apache for the PHP module to get loaded:
sudo systemctl restart apache2
Unlike Apache, Nginx doesn’t have built-in support for processing PHP files. We’ll use PHP-FPM (“fastCGI process manager”) to handle the PHP files.
Run the following commands to install PHP and PHP FPM packages:
sudo apt update
sudo apt install php-fpm
#ubuntu 20.04 #ubuntu #php #apache