Install PHP

Standard PHP Installation (PHP 8.2 for Debian 12 Bookworm)

The default version for modern Debian 12 systems.

sudo apt update
sudo apt install php libapache2-mod-php php-cli php-common php-mbstring php-gd php-intl php-xml php-mysql php-zip php-curl

Verify Installation

Check which version is currently active:

php -v

Legacy: PHP 7.3 (Old Debian Versions)

Only use this if you specifically need an older version.

sudo apt install php7.3 php7.3-cli php7.3-common php7.3-json php7.3-opcache php7.3-mysql php7.3-zip php7.3-fpm php7.3-mbstring
sudo a2enmod proxy_fcgi setenvif
sudo a2enconf php7.3-fpm
User