How install php in ubuntu step by step?

PHP is the language that is mostly used for server-side programming. It is executed, run, and must be installed on the webserver. Since it is an interpreted language, it doesn’t need any compiler. PHP handles the interaction between the front-end of the web pages and the back-end servers or databases.

Installation of PHP on Ubuntu 20.04 LTS

Before getting started with the installation of PHP, first, always update Ubuntu’s package repository.

How install php in ubuntu step by step?

After updating Ubuntu’s package repository, install the PHP by typing the command given below.

How install php in ubuntu step by step?

It will take a while to download and install the latest stable version of PHP.

Verify the installation of PHP on Ubuntu

Once it is installed successfully, you can verify and check the version of PHP by typing the “php -v” command.

How install php in ubuntu step by step?

Alright! You can now see that version 7.4.3 of PHP is installed on Ubuntu 20.04 LTS.

Install Apache PHP module

If you want to install other requisite software like Apache PHP Module with it, then type the command below.

$ sudo apt install libapache2-mod-php

How install php in ubuntu step by step?

Now restart the Apache server for the changes to take effect, and if you want to load the PHP module, type the following command.

$ sudo systemctl restart apache2

How install php in ubuntu step by step?

If it is restarted without throwing any error, you can verify it by checking the status using the command given below.

$ sudo systemctl status apache2

How install php in ubuntu step by step?

If it is active and running, then you are ready to go.

Find and Install Extensions of PHP on Ubuntu 20.04

In case you want to install some further extensions of PHP, you can type the following command in the terminal.

Then, hit the tab button twice on your keyboard to see the available extensions of PHP.

How install php in ubuntu step by step?

For example, if we want to install the PHP MySQL extension, the command would be like this:

$ sudo apt install php-mysql

It will ask you to take additional disk space for the extension to install, then press “y” to continue the process.

How install php in ubuntu step by step?

Downloading and installation of the PHP MySQL extension will start.

How install php in ubuntu step by step?

This is how you can find and install any extension of PHP of your desire.

Conclusion

This is the simplest way to install and get started with the PHP on Ubuntu 20.04 LTS. In this post, we have explained the installation of PHP and its extensions.

About the author

How install php in ubuntu step by step?

A Javascript Developer & Linux enthusiast with 4 years of industrial experience and proven know-how to combine creative and usability viewpoints resulting in world-class web applications. I have experience working with Vue, React & Node.js & currently working on article writing and video creation.

How do I download PHP on Ubuntu?

Installing PHP on Ubuntu 22.04.
Install few dependencies required by this tutorial with the below-mentioned command: sudo apt install software-properties-common ca-certificates lsb-release apt-transport-https..
Add the Ondrej PPA to your system, which contains all versions of PHP packages for the Ubuntu systems..

How do I install the latest PHP version in Ubuntu?

The guide below teaches you how to install the latest PHP on Ubuntu 22.04..
Step 1: Update the system. ... .
Step 2: Install Dependencies. ... .
Step 3: Import PPA Repository of PHP. ... .
Step 4: Install Apache module/PHP-FPM. ... .
Step 5: Verify installation. ... .
Step 6: Install Extensions..

How do I start PHP in Ubuntu?

How to run PHP on Ubuntu.
sudo apt-get install php. ... .
In order to restart Apache web server just type the following command sudo gedit /var/www/html/index. ... .
In this tutorial im using gedit to create my webpages but you can also install an IDE like netbeans and manage you projects from there in a way more efficient way..

How do I install PHP on Linux?

Follow the below steps to install PHP on Linux:.
Step 1: Open your terminal in Linux. On your Linux computer open the terminal. ... .
Step 2: Update your packages. On your terminal update your packages using the following command. ... .
Step 3: Upgrade your packages. ... .
Step 4: Install PHP..