How to Install PHP on Ubuntu 20.04

How to Install PHP on Ubuntu 20.04

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.

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.

Installing PHP 7.4 with Apache

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

Installing PHP 7.4 with Nginx

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

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

How to Install Apache Maven on Ubuntu 20.04 | 18.04 |

This brief tutorial shows students and new users how to quickly and easily install Apache Maven on Ubuntu 20.04 | 18.04. Apache Maven comes with the default Ubuntu repositories… so all it takes is…

How to Install Apache Ant on Ubuntu 20.04 | 18.04

This brief tutorial shows students and new users how to install Apache Ant on Ubuntu 20.04 | 18.04. Apache Ant is a Java library and tool that has number of built-in tasks allowing to compile, assemble, test and run Java applications. Apache Ant is a Java library and tool that has number of built-in tasks allowing to compile, assemble, test and run Java applications. If you’re...

How to Install Apache ActiveMQ on Ubuntu 20.04 | 18.04 |

This brief tutorial shows students and new users how to install Apache ActiveMQ on Ubuntu 20.04 | 18.04 server. For those who don’t know, Apache ActiveMQ is a free, multi-protocol, Java-based message…

How To Install Jenkins on Ubuntu 20.04 / Ubuntu 18.04

Jenkins is an open-source automation server that helps to automate the repetitive tasks involved in the software development process, which includes building, testing, and deployments. Jenkins was forked from the Oracle Hudson project and written in Java. Here, we will see how to install Jenkins on Ubuntu 20.04 / Ubuntu 18.04.

Install Memcached with Apache on Ubuntu 20.04 | 18.04 |

This brief tutorial shows students and new users how to install Memcached with Apache support on Ubuntu 20.04 | 18.04. Memcached is a free, open source, object caching program that allows repeated PHP…