Editor's PickFeaturedHighlightsLinuxPHPRaspberry
0

How to install PHP 8.2 on Raspberry Pi

PHP is a programming language that commonly used to create web applications and dynamic websites. With each release of PHP, new features and various changes are introduced.

This tutorial shows how to install PHP 8.2 on Raspberry Pi.

Install PHP

Connect to Raspberry Pi via SSH and execute command to download GPG key:

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

Add PHP repository:

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

Update the package lists:

sudo apt update

Next, install PHP 8.2 with command line interface (CLI):

sudo apt install -y php8.2-common php8.2-cli php8.2-curl php8.2-gd php8.2-mbstring php8.2-xml php8.2-zip php8.2-mysql libapache2-mod-php8.2 php8.2-imagick php8.2-intl

Check PHP version when installation was finished:

php --version

Uninstall PHP

If you want to completely remove PHP anything related to it, execute the following command:

sudo apt purge --autoremove -y php-common mime-support

Remove GPG key and repository:

sudo rm -rf /etc/apt/trusted.gpg.d/php.gpg
sudo rm -rf /etc/apt/sources.list.d/php.list

Remove PHP related file:

sudo rm -rf /var/lib/systemd/timers/stamp-phpsessionclean.timer

Install older versions

PHP 8.1 is an older version that is still supported. It can be installed by changing php8.2 to php8.1 in this post presented commands.

Leave a Reply

Your email address will not be published. Required fields are marked *