ItSolutionStuff.com

How to Install PHP in Ubuntu Server?

By Hardik Savani • May 14, 2024
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...

Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

How to Connect SSH using ppk File Ubuntu?

Read Now →

How to Connect to a Remote Server using SSH on Ubuntu?

Read Now →

How to Upgrade PHP Version from 7.4 to 8 in Ubuntu?

Read Now →

How to Export Mysql Database using Command Line in Ubuntu?

Read Now →

How to Import Database in Mysql using Command Line in Ubuntu?

Read Now →

How to Install Yarn npm in Ubuntu?

Read Now →

How to Upgrade PHP Version from 7.3 to 7.4 in Ubuntu?

Read Now →

How to Enable Apache mod_rewrite Module in Ubuntu?

Read Now →

How to create quick apache virtual host in Ubuntu?

Read Now →