Open In App

How to Install PHP on Linux?

PHP is a general-purpose scripting language that is especially used in web development. It was created in 1994 by Rasmus Lerdorf. It is used to manage dynamic content, databases, session tracking, and build entire e-commerce websites and Linux is an open-source operating system. It was first released on  17 September 1991  by Linus Torvalds. In this article, we will know that How can we install PHP on Linux operating system.

Prerequisites:

Installing 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. You can also open the terminal by using Ctrl+Alt+T.



Step 2: Update your packages

On your terminal update your packages using the following command.

#    sudo apt-get update

Step 3: Upgrade your packages

Now install available upgrades of all packages currently installed on the system using the following command.

#    sudo apt-get upgrade

Step 4: Install PHP

Now we are ready to install PHP. The following command will install PHP on our system.

#    sudo apt-get install php

After entering the above command a prompt will appear enter Y and press enter key. Within few minutes the latest version of PHP along with several extensions will install on your Linux system.

You can verify the PHP version after installation using the following command.

#    php --version

As you can see the output PHP version shown that means we have successfully installed PHP in our system.

Article Tags :