- How to Install Latest PHP 8.1 on Debian 11/10
- Prerequisites
- Installing PHP 8 on Debian Linux
- PHP and Debian
- The first place you should go for information
- How PHP is packaged in Debian
- Available versions
- Available packages
- Developer access
- Configuration layout
- Debian Jessie and below
- Debian Stretch and up
- For packagers of PHP applications/modules/libraries
- For those interested in helping with PHP in Debian
- Notes on PHP and security
- Errata
- Stretch 9 errata
- Jessie 8 errata
- Wheezy 7 errata
- Notes on Floating Point Rounding
- Further Information
- Как установить PHP на Debian 11
- Предпосылки
- Шаг 1 — Включение репозитория SURY
- Шаг 2 — Установка PHP на Debian 11
- Шаг 3 — Установка расширения PHP
- Шаг 4 — Проверка версии PHP
- Заключение
How to Install Latest PHP 8.1 on Debian 11/10
Debian is a secure and stable Linux-based operating system distribution offering unmetered server performance to web-based applications. Debian 11 “Bullseye” is profiled with improved security, exFAT file systems support, and multiple languages support as features that go hand in hand with numerous web-based applications.
Among the features and improvements paraded in PHP 8, the JIT compiler for web apps is most notable. Its benefits include better numerical code performance, better PHP web application code execution and performance, and potentially fast PHP code due to supported C to PHP code migration.
Other notable new/improved features in PHP 8 include strict type checks, especially for Bitwise/Arithmetic operators, saner numeric strings, nullsafe operator, named arguments, weak maps, throw expression, and constructor property promotion.
This article will give a walk-through on installing PHP 8 on Debian 11/10.
Prerequisites
Have root/sudoer user privileges on the Debian 11 system you are using.
Installing PHP 8 on Debian Linux
Updating your Debian system ensures it stays in the best-performing state on top of applying the needed security patches.
$ sudo apt update && sudo apt upgrade -y
If you have older PHP versions like 7.x, you might want to uninstall it to primarily benefit from the features and improvements attached to PHP 8.
$ sudo apt remove --purge php*
Next, install the required PHP 8 installation dependencies and also configure the UFT-8 Unicode standard.
$ sudo apt install -y lsb-release ca-certificates apt-transport-https software-properties-common gnupg2 $ sudo locale-gen en_US.UTF-8
Now add the Ondřej Surý PPA repository, which will be responsible for tracing, retrieving, and installing the latest PHP version on your Debian 11 system.
$ echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/sury-php.list $ sudo wget -qO - https://packages.sury.org/php/apt.gpg | sudo gpg --no-default-keyring --keyring gnupg-ring:/etc/apt/trusted.gpg.d/debian-php-8.gpg --import $ sudo chmod 644 /etc/apt/trusted.gpg.d/debian-php-8.gpg
After adding a repository, update the Debian system to recognize the inclusion of the Ondřej Surý PPA repository. Also, if future PHP versions are released, upgrading to them will require a simple Debian 11 system update command like the one below:
$ sudo apt update && sudo apt upgrade -y
Finally, install PHP 8.1 on Debian 11.
Confirm the installed php version.
To install other PHP extensions, reference the syntax:
$ sudo apt install php8.1-name_of_extension
For instance, to install a php-fpm extension, we will execute the command:
$ sudo apt install php8.1-fpm
This article has taught us how to install PHP and any of its associated extensions on Debian 11. You are now ready to pursue your web-based applications/projects.
PHP and Debian
This page contains information and links helpful for users and packagers of PHP software in Debian. It also contains any errata for the latest stable release of Debian. It is not meant to supercede documentation provided in the PHP packages, nor is it meant as a general reference for programming in PHP. For those see the Further Information section.
The first place you should go for information
/usr/share/doc/php*. Most notably, README.Debian and NEWS.Debian, just like any other package. Note that if you are visiting this page while following the directions in that file, abort now because you’re in an infinite loop
How PHP is packaged in Debian
Available versions
Please check the Debian PTS for specific version information.
PHP 4 was provided up to DebianEtch (php 4). It was removed and replaced by php5 in DebianLenny. PHP 7.0 was added in Stretch (php7.0).
Available packages
Up until Debian 8 (Jessie), for every M where M is a php major version, a metapackage phpN exists which will require at least one functioning php server engine installed (i.e. libapache2-mod-php5, php5-cgi, etc).
Since Debian 9 (Stretch), for every M.N where M is a php major version and N is a php minor version, a metapackage php exists which will require a default phpM.N package which will require at least one functioning PHP server engine (i.e. libapache2-mod-php7.0, php7.0-fpm or php7.0-cgi)
Beyond this, there’s always:
. will give you a long list of php related packages. For more specifics on the package naming schemes, you should check the PHP draft policy in Further Information.
Developer access
Configuration layout
Debian Jessie and below
For each major release N of PHP (where N is 4 or 5), each of the 4 SAPI’s (apache/apache2/cgi/cli) have a different central configuration file /etc/phpN/$SAPI/php.ini.
Additionally, each SAPI is configured with the compile-time option
--with-config-file-scan-dir=/etc/phpN/$SAPI/conf.d
Any file found in this directory ending in .ini will be treated as a configuration file by the PHP SAPI.
Debian Stretch and up
For each major.minor release M.N of PHP (where M is 7 and N is 0, 1, . ), each of the SAPI’s (apache2/cgi/fpm/cli/phpdbg/. ) have a different central configuration file /etc/php/M.N/$SAPI/php.ini
Additionally, each SAPI is configured with the compile-time option
--with-config-file-scan-dir=/etc/php/M.N/$SAPI/conf.d
Any file found in this directory ending in .ini will be treated as a configuration file by the PHP SAPI.
The environment variable PHP_INI_SCAN_DIR can be set to override the compile-time option.
For packagers of PHP applications/modules/libraries
You should consider taking a look at the PHP draft policy. There’s also a mailing list for web applications packagers, debian-webapps@lists.debian.org . While the list is technically for webapp packaging-related issues, you should feel welcome to post purely PHP-packaging-related questions as well, as there is a significant overlap in the audience and you’re more likely to get a response from here than from mailing the PHP packagers.
The extensions are expected to install their configuration to /etc/php/M.N/mods-available for each M.N tuple the extension has been compiled with and enable the extension as appropriate using /usr/lib/php/php-maintscript-helper.
The easiest way how to package PECL extension is to use dh-php package and helpers included within this package.
For those interested in helping with PHP in Debian
The first thing you should do is send an email to the Debian PHP maintainer’s list, pkg-php-maint@lists.alioth.debian.org. Help is often needed and always appreciated. See also the php group team
Notes on PHP and security
It’s highly recommended that you read README.Debian.security in /usr/share/doc/php*.
- issues involving features that are broken as designed (safe mode, register globals, etc) are completely ignored
- issues that require a malicious local user (unless there are compelling reasons otherwise) are ignored.
- issues involving unsafe application usage (applications not filtering input before passing to certain functions) are usually given a low priority or sometimes even ignored in favor of reporting bugs against the offending applications
- issues involving remote code execution (buffer overflows, code inclusion, etc) are given the highest priority
The Debian PHP maintainers work fairly closely with the Debian security (esp. secure-testing) teams, as well as the Ubuntu PHP maintainers, so you can be generally assured that properly reported bugs tagged as security-relevant will be handled as promptly and transparently as possible.
Errata
Stretch 9 errata
Stretch 9 is now stable. No errata has been logged here for it.
Jessie 8 errata
Jessie 8 is now oldstable. No errata has been logged here for it.
Wheezy 7 errata
Wheezy 7 is now oldoldStable. No errata has been logged here for it.
Notes on Floating Point Rounding
See PHP/Rounding for some discussion of why floating point rounding does not behave as expected.
Further Information
- /usr/share/doc/php*
- Official php homepage
- PHP: Debian Installation — manual
- php-security.org, authors of hardened php and frequent auditors of php’s security.
- Bugs against php5 source package
- Draft PHP packaging policy
- Debian PHP maintainer’s list: pkg-php-maint@lists.alioth.debian.org (Browse the list)
- Debian webapps mailing list: debian-webapps@lists.debian.org (Browse the list)
Как установить PHP на Debian 11
PHP, сокращенно называемый «HyperText Processor», — это язык программирования с открытым исходным кодом, используемый для разработки веб-приложений. Это язык сценариев, который в основном используется для интерфейса с HTML. Его можно использовать для создания веб-сайтов электронной коммерции, управления базами данных и мониторинга сеансов.
Доступно для всех ОС. Последней версией PHP является версия 8, и в этой статье мы обсудим установку PHP в системе Debian 11 Bullseye Linux.
Выполните следующие шаги для успешной установки PHP в вашей системе Debian:
Предпосылки
Сначала обновите все пакеты системы с помощью указанной ниже команды:
После обновления пакетов теперь установите зависимости, необходимые для указанной ниже команды:
sudo apt install software-properties-common ca-certificates lsb-release apt-transport-https
Шаг 1 — Включение репозитория SURY
Следующим шагом является интеграция репозитория SURY в нашу систему. SURY — это сторонний репозиторий PHP на основе Debian, который объединяет программное обеспечение PHP, выполните следующую команду, чтобы добавить репозиторий SURY:
sudo sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
Импорт ключа GPG для репозитория с помощью указанной ниже команды:
wget -qO - https://packages.sury.org/php/apt.gpg | sudo apt-key add -
Шаг 2 — Установка PHP на Debian 11
Теперь снова обновите пакеты для их синхронизации с недавно добавленным репозиторием SURY перед установкой php:
Репозиторий SURY содержит PHP 8.0, 7.4, 7.3, 7.2. 7.1, 7.0 и PHP 5.6. Поскольку последняя стабильная версия PHP — 8.0, но для большого количества веб-сайтов по-прежнему требуется PHP 7. Этот репозиторий также включает пакеты PHP 8.1, который в настоящее время находится в стадии бета-тестирования. Вы можете установить в своей системе любую из необходимых версий PHP.
Выполните следующую команду, чтобы установить PHP 8 в Debian 11:
Чтобы установить любое другое изменение версии, замените 8.8 его версией, которую вы хотите установить. Вы также можете установить несколько версий в одной системе.
Шаг 3 — Установка расширения PHP
Кроме того, мы также можем добавить расширение php с помощью синтаксиса, указанного ниже:
sudo apt install php8.0-[extension]
Замените [extension] расширением, которое вы хотите установить. Если вы хотите добавить несколько расширений, включите их в фигурные скобки, я собираюсь установить «php-mbstring, php-cli, php-xml, php-common и php- curl », выполнив указанную ниже команду:
sudo apt install php8.0-cli php8.0-mbstring php8.0-xml php8.0-common php8.0-curl
Пользователи установили другую версию PHP, ее необходимо заменить 8.0 на требуемую версию PHP.
Шаг 4 — Проверка версии PHP
Теперь после установки убедитесь, что установлена правильная версия PHP, проверив номер версии с помощью указанной ниже команды:
PHP 8.0.10 (cli) (built: Aug 26 2021 16:06:19) ( NTS ) Copyright (c) The PHP Group Zend Engine v4.0.10, Copyright (c) Zend Technologies with Zend OPcache v8.0.10, Copyright (c), by Zend Technologies
Заключение
PHP — это бесплатный серверный язык программирования, который также используется с языком программирования HTML для создания динамических веб-сайтов. Он доступен для всех операционных систем, но в этой статье мы обсудим его установку в Debian 11 (ОС Linux) Bullseye. Вы успешно установите PHP на Debian 11, прочитав это руководство.