How to Install PHP 8.2 for Apache on Debian 12

PHP (Hypertext Preprocessor) is a popular server-side scripting language designed for web development. It is primarily used to create dynamic web pages and perform various server-side tasks. PHP code is embedded within HTML documents and executed on the server, generating dynamic content that is then sent to the user's web browser.

To install PHP 8.2 for Apache on Debian 12, you can follow these steps:

Step 1 : Install the necessary packages to add the Sury repository:

Step 2 : Import the Sury GPG key:

Step 3 : Add the Sury repository to your package sources:

Step 4 : Update the package list to include the Sury repository:

Step 5 : Install PHP 8.2 for Apache:

Step 6 : Install the required extensions for PHP 8.2:

Step 7 : Enable the PHP module for Apache:

Step 8 : Restart Apache to apply the changes:

Step 9 : Optional: Test your PHP installation.

Create a PHP info file to test if PHP is working correctly. Create a new file called info.php in your web server's document root directory (usually /var/www/html/):

Add the following line to the file:

Save the file and exit the text editor.

Open a web browser and navigate to http://your_server_ip/info.php. Replace your_server_ip with the actual IP address or domain name of your server. You should see the PHP information page if PHP is installed and configured correctly.

You have successfully installed PHP 8.2 for Nginx on Debian 12. You can now configure your website's files and test your PHP scripts.