Step-by-Step Guide For Installing PHP 8.3 on Debian 11

In this article, you will learn a Step-by-Step Guide For Installing PHP 8.3 on Debian 11. Also, you can complete your setup with Apache and Nginx modules. PHP 8.3 is the latest version of the PHP programming language. PHP (Hypertext Preprocessor) is a widely used open-source scripting language that is especially suited for web development and can be embedded into HTML. Also, it comes with new improvements and features. To get more information, you can check Introduce PHP 8.3 and New Improvements.

In this article, we show you how to install PHP 8.3 on Debian 11. If you have an older PHP version installed on your server and you want to upgrade it, you can check Upgrade Default PHP to PHP 8.3 in Debian.

Quick Guide for Installing PHP 8.3 on Debian 11

Before you start your setup, you must log in to your server as a non-root user with sudo privileges. For this purpose, you can check the Debian 11 Initial Setup Guide.

Now follow the steps below to complete this guide.

Step 1 – Add PPA Repository To Debian 11

To get the latest PHP 8.3, you need to add the PPA PHP Sury Repo to your Debian 11. First, install the required packages with the command below:

sudo apt -y install lsb-release apt-transport-https ca-certificates

Then, use the following wget command to add the PPA repo and GPG key:

# sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
# sudo echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list

Next, run the system update:

sudo apt update

Step 2 – Install the Latest PHP 8.3 on Debian 11

Now you can simply use the following command to install PHP 8.3 on your server:

sudo apt install php8.3 -y

Once your installation is completed, verify it by checking its version:

php -v
Install the Latest PHP 8.3 on Debian 11

Step 3 – PHP 8.3 Setup with Apache on Debian 11

PHP works with the Apache web server through a module called mod_php. To install PHP 8.3 with the Apache module, you need to run the following command:

sudo apt install libapache2-mod-php8.3 -y

Also, you can install and enable PHP-FPM with the commands below:

# sudo apt install php8.3-fpm libapache2-mod-fcgid -y
# sudo a2enmod proxy_fcgi setenvif 
# sudo a2enconf php8.3-fpm

Restart your Apache service to apply the changes:

sudo systemctl restart apache2

Step 4 – PHP 8.3 Setup with Nginx on Debian 11

PHP can work with the Nginx web server using FastCGI Process Manager (PHP-FPM). Unlike Apache, Nginx does not have built-in support for processing PHP code. Instead, it relies on external processes to handle PHP requests.

To install PHP 8.3 with Nginx you can run the command below:

sudo apt install php8.3-fpm php8.3-cli -y

Your PHP-FPM is activated automatically. This is an example for all server blocks that process PHP files that need the location ~ .php$ added.

server {
# … some other code
location ~ .php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.3-fpm.sock;
}

Conclusion

By installing PHP 8.3 in Debian 11, developers can build robust, secure, and scalable web applications that meet the demands of modern web development. Hope you enjoy it.

Also, you may like to read the following articles:

Steps To Run PHP 8.3 on Linux Mint 21

Quickly Install PHP 8.3 on Fedora Linux 39

PHP 8.3 Installation on AlmaLinux 9 / Rocky Linux 9

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Leave a Reply

Stay informed and not overwhelmed, subscribe now!