It looks like the package for PHP 8.1 is not available in the default package repository for your Bullseye distribution. You may need to add a different package repository or build PHP 8.1 from source.
First, you can try adding the Debian Backports repository to your system by adding the following line to your /etc/apt/sources.list file:
deb
http://deb.debian.org/debian bullseye-backports main
Then, run sudo apt update to update the package lists, and try installing PHP 8.1 again with:
sudo apt install -t bullseye-backports php8.1
If that doesn't work, you could try building PHP 8.1 from source. Here are the general steps:
Install the required dependencies for building PHP:
sudo apt-get update
sudo apt-get install build-essential libssl-dev libcurl4-openssl-dev libxml2-dev libreadline-dev libzip-dev
Download the PHP 8.1 source code from the official website:
wget
https://www.php.net/distributions/php-8.1.0.tar.gz
tar -zxvf php-8.1.0.tar.gz
cd php-8.1.0
Configure the PHP build with the necessary options:
./configure --prefix=/usr/local/php --enable-mbstring --with-curl --with-openssl --with-readline --with-zip
Build and install PHP:
make
sudo make install
Verify that PHP is installed by running:
/usr/local/php/bin/php -v
Keep in mind that building PHP from source can be a more involved process than installing it from a package, and may require additional steps depending on your specific configuration.