Released on February 15, 2024, PHP 8.3.3 is the latest version of the widely-used PHP programming language for web development. This release introduces numerous improvements and new features that enhance the performance, security, and usability of PHP.
There are three PHP versions you can install on Debian 11/12: 8.1, 8.2, and 8.3. While the process may seem straightforward, it can present challenges for many users. We offers a new solution to help you succeed in installing PHP, whether you encounter errors or have never gone through the process before.
Notes before implementation:
- This guide only works well for Debian 11 and 12 operating system.
- You need sudo or root permissions to do this.
Step 1: Create a trusted certificate signature for PHP
The initial step to install PHP 8.1,8.2 and 8.3 on Debian 11 is to create and verify a signature from the Surý APT repository.
- Create files
php.gpg
in foldertrusted.gpg.d
. This file will store the GPG key of the Surý APT repository. - Download the GPG key from the URL https://packages.sury.org/php/apt.gpg and store it in a
php.gpg
.
Reasons to take these steps:
- Surý APT repository is a reputable development team with extensive experience in providing PHP packages for Debian. Using a GPG key ensures that you only install official and safe PHP packages.
- GPG keys help verify the authenticity of PHP packages downloaded from the Surý APT repository.
sudo touch /etc/apt/trusted.gpg.d/php.gpg sudo wget -qO /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
Step 2: Add PHP (8.1/8.2/8.3) apt repository to the list
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/sury-php.list
This command adds a path to Ondřej Surý’s repository for PHP versions 8.1 to 8.3. This allows the system to easily install and update any of these PHP versions from the repository when you update or install software packages. You won’t need to search for or install PHP from external sources.
Step 3: Update system and install PHP on Debian 11
sudo apt update sudo apt install php8.1
This command will easily and automatically install PHP version 8.1 on your Debian 11 system along with related dependent packages.
Similarly, if you want to install PHP 8.2, the command will be:
sudo apt install php8.2
Or install PHP 8.3 on Debian:
sudo apt install php8.3
Step 4: Install Additional PHP Extensions and PHP 8 FPM
Here is the command to install php8.1-fpm and its extensions for Debian 11. Feel free to substitute the version number, such as 8.2 or 8.3, to install a specific version.
sudo apt install php8.1-common php8.1-mysql php8.1-xml php8.1-xmlrpc php8.1-curl php8.1-gd php8.1-imagick php8.1-cli php8.1-dev php8.1-imap php8.1-mbstring php8.1-opcache php8.1-soap php8.1-zip php8.1-intl php8.1-fpm php8.1-zip php8.1-bcmath php8.1-mcrypt
Once you have successfully installed PHP 8.1 on Debian 11, start php8.1-fpm and allow it to boot with the system.
sudo systemctl enable php8.1-fpm sudo service php8.1-fpm restart
Note: If you encounter errors related to permissions (permission denied), you can refer to the php8-fpm configuration article to fix the errors.
Frequently asked questions:
How can I check the installed PHP version?
You can use the following command to check the installed PHP version: php -v
What do I need to install PHP on Debian 11?
A computer or VPS running Debian 11 operating system.
Root access or sudo privileges.
Internet connection.
Where can I find more information about PHP?
You can visit the official PHP website at: https://www.php.net/
Why should I install PHP 8.3?
PHP 8.3 brings numerous improvements and new features that enhance performance, security, and usability of PHP. Some notable enhancements include:
+ Significant performance improvements
+ Support for JIT compiler
+ New security features
+ New syntax
Do I need to install other PHP extensions?
The installation of additional PHP extensions depends on your needs. If you require specific functionalities, you will need to install the corresponding extensions.