How to Install PHP in 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
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- How to Connect SSH using ppk File Ubuntu?
- How to Connect to a Remote Server using SSH on Ubuntu?
- How to Upgrade PHP Version from 7.4 to 8 in Ubuntu?
- How to Export Mysql Database using Command Line in Ubuntu?
- How to Import Database in Mysql using Command Line in Ubuntu?
- How to Install Yarn npm in Ubuntu?
- How to Upgrade PHP Version from 7.3 to 7.4 in Ubuntu?
- How to Enable Apache mod_rewrite Module in Ubuntu?
- How to create quick apache virtual host in Ubuntu?