To install PHP 8.2 for Nginx on Ubuntu 22.04, you can follow these steps:
Step 1 : Update the System : Make sure your package list and installed packages are up to date.

Step 2 : Install Software Properties Common

Step 3 : Add the Ondřej Surý PPA
You need to add the Ondřej Surý PPA to your system:

Step 4 : Install PHP 8.2 Core

This command installs the core PHP 8.2 package.
Step 5 : Install Required PHP Extensions
Install additional PHP extensions based on your project's requirements. Here's an example with commonly used extensions:

You can install additional PHP extensions based on your requirements.
Step 6 : Configure Nginx to use PHP
Create a new Nginx server block configuration:
Replace "example.com" with your domain or server IP. Add the following configuration:

Save and exit the file. Create a symbolic link to enable the site:

Test the Nginx configuration:

If the test is successful, reload Nginx to apply the changes:

Step 7 : Verify PHP Installation
Create a PHP file in your web root to verify the installation. For example:
Add the following content:

Save the file and access it in your web browser (e.g., http://your_domain_or_ip/info.php). You should see the PHP information page.

You should now have PHP 8.2 installed and configured with Nginx on Ubuntu 22.04.