PHP is compatible with different operating systems like Windows, macOS, Ubuntu, and Raspberry Pi OS, also is compatible with different servers like Apache. In this write-up, PHP’s latest version installation has been explained on Raspberry Pi.
How to install the latest PHP on Raspberry Pi
The pre-included repository of Raspberry Pi does not contain the latest release of PHP so we will not install the PHP on Raspberry Pi using the repository of Raspberry Pi. First, we will update the repository of the Raspberry Pi using the command:
We will download the dependencies needed to install the packages of PHP on Raspberry Pi using the command:
After installation of these dependencies, we will download the gpg package from https://packages .sury.org and save it to /etc/apt/trusted.gpg.d/php.gpg using the command:
Import the downloaded package to the Raspberry Pi repository using the command:
After configuring the PPA repository, we will update the Raspberry Pi repository using the apt package manager:
We can see that 19 packages needed upgradation, so we will upgrade them using the command:
To install the php8.1, run the command:
To authenticate the installation of the latest version of the PHP on Raspberry Pi, we will check its version:
To display the loaded PHP modules, use the command:
To remove the package of PHP 8.1 from the repository of the Raspberry Pi, use the command:
Conclusion
PHP is used in web development to create interactive dynamic websites; it is also used to take the input from the users on the websites and update the information according to the information (gathered from the users) in the databases. In this write-up, the latest PHP version has been installed by adding a PPA repository because in the repository of Raspberry Pi the 8.1 version of PHP is not available.