To install PHP 7.4 on Ubuntu 23.04, follow the steps below.
Step 1 : Ensure your system is up-to-date by running the following command:

Step 2 : Add the PHP Repository
Since ppa:ondrej/php does not officially support non-LTS versions, follow these steps:
- Add the Repository (ppa:ondrej/php)

- Open the file

Find "lunar" and replace it with "jammy". Save the file.

Step 3 : Update Again

Step 4 : Set Package Preferences
Create the file /etc/apt/preferences.d/ondrejphp and add the following code:
Add the following lines:

Save the file.
Step 5 : Install PHP 7.4 Core

Step 6 : Install commonly used PHP extensions:

Explanation of Extensions:
- mysql: MySQL database support
- curl: cURL support for making HTTP requests
- json: JSON support
- xsl: XSL extension for XML manipulation
- gd: GD graphics library support for image processing
- xml: XML support
- zip: ZIP archive support
- soap: SOAP protocol support
- bcmath: Arbitrary precision mathematics support
- mbstring: Multibyte string support
- gettext: Gettext support for message translation
- imagick: ImageMagick support for image manipulation
Step 7 : Check PHP Version

Congratulations, you have successfully installed PHP 7.4 on Ubuntu 23.04 with the necessary extensions.