How to Install PHP 8 on Debian 12 – Simple Guide

In the world of web development, having the right tools at your disposal is crucial. PHP 8, the latest version of the popular scripting language, brings with it a host of new features and improvements that can elevate your web projects. If you’re running Debian 12 and looking to harness the power of PHP 8, you’re in the right place.

In this guide, we will walk you through the straightforward steps to install PHP 8 on Debian 12.


  • Debian 12 Installed system
  • Sudo User with admin rights
  • Internet connection

Without any further delay, let’s jump into PHP 8 installation steps on Debian 12 system.

Installing PHP 8 Using Default Package Repositories

Debian 12  default package repositories has PHP 8.2, so it’s installation is straightforward using following apt commands. Open terminal and run beneath commands,

$ sudo apt update $ sudo apt install php -y


Once PHP 8 packages are installed, verify the PHP version by running,

$ php -v


In order to extend PHP functionalities, install its famous extensions using beneath command,

$ sudo apt install -y php-{curl,mbstring,zip,xml,soap,cli}


Installing PHP 8 via Sury PPA

In case, you want to install latest version of PHP 8, then enable Sury PPA repository. Execute following set of commands to enable Sury PPA,

$ sudo wget -O /etc/apt/trusted.gpg.d/php.gpg
$ echo "deb $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list
$ sudo apt update


At time of writing this guide, php 8.3 was the latest version available in Sury PPP. So to install it run,

$ sudo apt install php8.3 -y


Check the php version post installation,

$ php -v


Configure PHP 8 for Apache Web Server

To configure PHP 8 for the web applications like Apache web server, edit its configuration file ‘/etc/php/8.2/apache2/php.ini’, add or change the below parameters that suits to your application

$ sudo vi /etc/php/8.2/apache2/
-------------------------upload_max_filesize = 16M
post_max_size = 30M
memory_limit = 128M
max_execution_time = 500
max_input_vars = 2000
max_input_time = 1000

Save & close the file. To make the above changes into the effect restart Apache service

$ sudo systemctl restart apache2

Foe NGINX web server, edit its configuration file ‘/etc/php/8.2/fpm/pool.d/www.conf‘ and set the parameters that suits to your nginx server setup. After making the changes to file, don’t forget to restart php 8 fpm service

$ sudo systemctl restart php8.2-fpm

Test PHP 8 Installation

Create a simple PHP script to verify that everything is working correctly. Use your preferred text editor to create a file called info.php in your web server’s root directory. For Apache, it’s usually /var/www/html/

$ sudo vi /var/www/html/info.php

Save & exit the file.

Now, open your web browser and navigate to http://your_server_ip/info.php (replace your_server_ip with your server’s actual IP address). You should see a page displaying extensive information about your PHP installation. If this page loads successfully, congratulations! PHP 8 is up and running on Debian 12.


Perfect, above screen confirms that PHP 8.2.9 has been installed successfully on your Debian 12 system. That’s all from this guide, please don’t hesitate to share your feedback and comments in below comments section.

Share on:

I am a Cloud Consultant with over 15 years of experience in Linux, Kubernetes, cloud technologies (AWS, Azure, OpenStack), automation (Ansible, Terraform), and DevOps. I hold certifications like RHCA, CKA, CKAD, CKS, AWS, and Azure.

3 thoughts on “How to Install PHP 8 on Debian 12 – Simple Guide”

  1. Hello,
    Thanks for your tutorial.
    I flow your instruction but I got at the end PHP Version 7.3.28-2+0~20210604.85+debian10~1.gbp219f11.
    I use Debian 10 on root server und also ISPConfig.
    I will be glad, if you could help me.
    Thanks und best Regards,

    • Hi Joseph,
      It seems like apt have used default Debian 10 package repositories for installing PHP 8.
      Please cross check whether you have enabled php 8 repository and updated the repositories using ‘apt update’ command


Leave a Comment