Install php 8.1 debian 10
PHP 8.1 is a significant update of the PHP language that will be “officially” released on November 25, 2021. This is a standard upgrade going forward from the existing PHP 8.0 release with the new PHP 8.1 is bringing enums, fibers, never return type, final class constants, intersection types, read-only properties amongst the long list of new features and changes. Show In the following tutorial, you will learn how to import the Ondřej Surý Repository and install PHP 8.1 on your Debian 10 Buster desktop or server. Table of Contents 1
Update Debian SystemUpdate your Debian operating system to make sure all existing packages are up to date:
Install Required DependenciesYou will need to have the following packages installed for this tutorial. Execute the following command to install:
Note, if unsure, run the command regardless; it will not harm your system. Import Ondřej Surý PHP RepositoryThe first step is to import and install the GPG key and repository which can be done using an automated script initiated by the curl command. In your terminal, use the following command.
Next, refresh your APT repository list to reflect the changes.
After running the update command, you may notice some packages require updating, make sure to do this before continuing.
Install PHP 8.1 with Apache OptionIf you run an Apache HTTP server, you can run PHP as an Apache module or PHP-FPM. Install Apache ModuleTo install PHP 8 as an Apache module, enter the following command.
Once installation is complete, restart your Apache server for the new PHP module to be loaded.
Install Apache with PHP-FPMPHP-FPM (an acronym of FastCGI Process Manager) is a hugely popular alternative PHP (Hypertext Processor) FastCGI implementation. To install PHP-FPM with the following commands.
Note, by default, PHP-FPM is not enabled for Apache. You must enable it by the following command.
Lastly, restart Apache.
Verify that PHP-FPM is working:
Install PHP 8.1 with Nginx OptionNginx does not contain native PHP processing like some other web servers like Apache. You will need to install PHP-FPM “fastCGI process manager” to handle the PHP files. First, check for updates on your system and install PHP-FPM, natively installing the PHP packages required. In your terminal, use the following command to install PHP 8.1 and PHP 8.1-FPM.
Once installed, the PHP-FPM service should be automatically started, if not run the following command.
You will need to edit your Nginx server block and add the example below for Nginx to process the PHP files. Below, example for all server blocks that process PHP files that need the location ~ .php$ added.
Test Nginx to make sure you have no errors with the adjustments made with the code above; enter the following.
Example output:
Restart Nginx service for installation to be complete.
In the tutorial, you have learned how to install PHP 8.1 and configure how to use it with Apache and Nginx. PHP 8.1 is exciting. However, at the current moment, it is still coming out of beta and not considered stable, such as 8.0 or the old stable 7.4, so beware you may find that many of your favorite software like WordPress or Plugins/Themes for CMS software may conflict until developers can update. Do some research, prepare, and have PHP 7.4 or 8.0 installed and ready to replace if anything goes wrong when making the switch. The stable versions such as 8.0 are still actively developed, and packages are pushed simultaneously along with the 8.1 packages. |