Open In App

How to Install PHP on Raspberry Pi?

PHP is a scripting language. It is used for Web Development purposes. Along with HTML and Javascripts PHP is highly used in different aspects. We all can be used PHP in our machine just by installing it. But, while you are using it in Raspberry Pi we have to install properly Raspberry Os. It is the most important prerequisite. Without it, you can not be able to install and use it further. If you do not install Raspberry Pi Os then you can not open the terminal which was provided along with it. If you can not open the terminal you can not write the proper commands to install the PHP or any other applications.

Features:



Install PHP on Raspberry Pi

To install PHP on Raspberry Pi follow the following steps:

Step 1: Open the terminal of Raspberry Pi Os, then write the following command to connect to Raspberry Pi via SSH and then download the GPG key:



sudo wget -qO /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg

Step 2: Now add the PHP repository using the following command: 

echo “deb https://packages.sury.org/php/ $(lsb_release -sc) main” | sudo tee /etc/apt/sources.list.d/php.list

Step 3: Now using the following command update the package list.

sudo apt update

Wait till the process is completed.

Step 4: Then write the following command to install PHP with a command-line interface. 

sudo apt install -y php8.1-common php8.1-cli

Wait till the process is completed.

Step 5: Now, your installation is successful. Write the following command to check the version of the installed PHP.

php –version

Here, PHP 8 version is installed. As in my machine, it is the right version I have to install. You can also install it on your machine, PHP 8 version works well than others.

Article Tags :