How to Install PHP in Ubuntu Server?

By Hardik Savani May 14, 2024 Category : Ubuntu Server

Hi,

This post is focused on how to install php in ubuntu server?. i would like to show you how to install php on ubuntu server 20.04. This tutorial will give you simple example of ubuntu php install command. this example will help you how to install php 8 in ubuntu 20.04. you will do the following things for how to install php 8 in ubuntu.

In this post, i will give you step of command how to install php and php-fpm, so let's see bellow commands how to install php in ubuntu server.

Few days ago i publish post how to install apache2 in ubuntu, so you want to see then click here.

Install PHP with Apache on Ubuntu

Update Local Package:

sudo apt update

Install software-properties-common:

sudo apt install software-properties-common

Add the ondrej/php PPA:

sudo add-apt-repository ppa:ondrej/php

Update Local Package:

sudo apt update

Install PHP:

Install PHP 8.0

sudo apt -y install php8.0

Install PHP 7.4

sudo apt -y install php7.4

you can see terminal layout as bellow:

Now you can check php version by following command:

php -v

you can see terminal layout as bellow:

Install PHP Packages:

Install PHP 8.0

sudo apt-get install php8.0-mysql php8.0-curl php8.0-cgi php8.0-xsl php8.0-mbstring

Install PHP 7.4

sudo apt-get install php7.4-mysql php7.4-curl php7.4-cgi php7.4-xsl php7.4-mbstring

Install PHP fpm with Nginx on Ubuntu

Update Local Package:

sudo apt update

Install software-properties-common:

sudo apt install software-properties-common

Add the ondrej/php PPA:

sudo add-apt-repository ppa:ondrej/php

Update Local Package:

sudo apt update

Install PHP:

Install PHP 8.0 fpm

sudo apt -y install php8.0-fpm

Install PHP 7.4 fpm

sudo apt -y install php7.4-fpm

Now you can check php version by following command:

php -v

Install PHP Packages:

Install PHP 8.0

sudo apt-get install php8.0-mysql php8.0-curl php8.0-cgi php8.0-xsl php8.0-mbstring

Install PHP 7.4

sudo apt-get install php7.4-mysql php7.4-curl php7.4-cgi php7.4-xsl php7.4-mbstring

I hope it can help you...

Tags :
Shares