To install PHP 7.4 on Ubuntu 22.04, you can follow these steps:
Step 1 : Update Package Information:

Step 2 : Add the Personal Package Archive (PPA):
Now, add the ondrej/php PPA to your system. This PPA offers PHP versions that are not available in the default Ubuntu repositories.

Step 3 : Update Package Information Again:
After adding the PPA, refresh the package information again.

Step 4 : Install PHP 7.4

Step 5 : Install Essential Extensions:
Next, install essential extensions that enhance PHP's functionality.
php7.4-mysql: Adds MySQL support for PHP, allowing interaction with MySQL databases.php7.4-curl: Enables PHP to make HTTP requests and interact with web services.php7.4-json: Provides encoding and decoding of JSON data.php7.4-xsl: Adds XSLT support for XML transformations.php7.4-gd: Provides image manipulation capabilities.php7.4-xml: Provides functionality for parsing and generating XML documents.php7.4-zip: Enables creation and extraction of zip archives.php7.4-soap: Adds SOAP support for web services.php7.4-bcmath: Offers arbitrary precision arithmetic functions.php7.4-mbstring: Provides multibyte character encoding support for strings.php7.4-gettext: Enables internationalization (gettext) functions.php7.4-imagick: Adds support for the Imagick image manipulation library.
You can install these extensions with the following command:

Step 6 : Verify PHP Installation:
To confirm that PHP 7.4 is successfully installed, run:

This command will display information about the installed PHP version.

You have successfully installed PHP 7.4 on Ubuntu 22.04