Install PHP on Debian 12

I thought that the most common language in the world should be a piece of cake to install.

Struggling for some hours with different versions an tons of dependencies I am still stuck.

Is there a One-Button-Installer for PHP on Debian12? And which version should it be?
Or is there a good instruction?

Does https://www.php.net/manual/en/install.unix.debian.php not work for some reason?

This is an Apache installation? I forgot to mention that I use Nginx…

Have you tried ChatGPT with the prompt "how to install php on debian using nginx"? The steps there don’t seem to difficult.

Yes. chatGPT did not make it. Bard on the other hand got it more correct. Almost. There are two dependencies that it could not solve or explain. pdo and openssl.

sudo apt update
sudo apt upgrade -y
sudo apt install php
sudo apt install php8.2-curl
sudo apt install php8.2-dom
sudo apt install php8.2-common
sudo apt install php8.2-gd
sudo apt install php8.2-fpm
sudo apt install php8.2-mbstring
sudo apt install php8.2-openssl (missing!)
sudo apt install php8.2-pdo_mysql (mising!)
sudo apt install php8.2-tokenizer (php8.2-common)
sudo apt install php8.2-zip
php -v

Nice one-button-installer :slight_smile:

Finally I got an answer.

pdo_mysql is installed by mysql
openssl is installed by the common

So here is the complete installation.

sudo apt install php
sudo apt install php8.2-curl
sudo apt install php8.2-dom
sudo apt install php8.2-common <-- openssl
sudo apt install php8.2-mysql <-- pdo_mysql
sudo apt install php8.2-gd
sudo apt install php8.2-fpm
sudo apt install php8.2-mbstring
sudo apt install php8.2-zip

Crystal clear for a PHP newbie…

1 Like