How to Install PHP on Raspberry Pi?
Last Updated :
14 Feb, 2022
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:
- PHP is very easy to use rather than other scripting languages.
- It is faster than other scripting languages.
- It can be installed in any operating system like macOS, Windows, Linux, etc.
- In PHP there is no need for compilation, as it is an interpreted language.
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.
Similar Reads
How to Install WordPress on Raspberry Pi? Installing WordPress on a Raspberry Pi is a fantastic way to create a low-cost, energy-efficient web server for your blog or website. This guide will walk you through the process, making it simple even if youâre new to WordPress and Raspberry Pi.PrerequisitesBefore we begin, ensure that you have the
6 min read
How to install PHP on Godaddy server? GoDaddy VPS is a shared server that provides computational services, databases, storage space, automated weekly backups, 99% uptime, and much more. Itâs a cheaper alternative to some other popular cloud-based services such as AWS, GPC, and Azure. PHP or Hypertext Preprocessor is an open-source and g
2 min read
How to Install PHP on Ubuntu? If you're working with web development on Linux, knowing how to install PHP on Ubuntu is essential. PHP is a popular server-side scripting language used to build dynamic websites, and setting it up on your Ubuntu system is simple. In this guide, we'll walk you through the steps to PHP installation o
5 min read
How to Install PHP on Linux? 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 P
2 min read
How to Install PHP on MacOS? PHP (Hypertext Preprocessor) is known as a general-purpose scripting language that can be used to develop dynamic and interactive websites. It was among the first server-side languages that could be embedded into HTML, making it easier to add functionality to web pages without needing to call extern
3 min read