How to Install PHP on Linux? (original) (raw)
Last Updated : 05 Sep, 2024
PHP is a popular server-side scripting language that is especially used in web development. If you’re working on a Linux environment, whether it’s a personal development setup or a production server, you will likely need PHP installed. In this article, we will see the step-by-step guide to install PHP on Linux operating system.
Prerequisites to Install PHP
- Linux machine – Linux operating system (Ubuntu)
- Access to a terminal with root or sudo privileges.
- An internet connection to download packages.
Steps to Install PHP on Linux Operating System
Follow the below steps to install PHP on Linux system:
**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.