Because the Ondrej PHP PPA repo is not supported in Ubuntu 23.04, I recommend installing PHP 8.1 through the default Ubuntu 23.04 apt packages.
Prerequisites
- sudo privileges
Install PHP 8.1 on Ubuntu 23.04
Step 1. Update the packages.
sudo apt update
Step 2. Install php 8.1:
sudo apt install php8.1
Step 5. Verify that PHP 8.1 is installed.
php -v
Conclusion
Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.