Linux. Обновление PHP

Узнаем текущую версию ОС:

cat /etc/*release
PRETTY_NAME=”Debian GNU/Linux 10 (buster)”
NAME=”Debian GNU/Linux”
VERSION_ID=”10″
VERSION=”10 (buster)”

Узнаем текущую версию PHP:

php -v
PHP 7.3.31-1~deb10u1 (cli) (built: Oct 24 2021 15:18:08) ( NTS )

То есть, мы будем обновлять PHP 7.3.31 до версии 8.1 на ОС Debian 10.

Посмотрим, какие расширения PHP у нас установлены:

apt list --installed | grep php
libapache2-mod-php7.3/oldstable,oldstable,now 7.3.31-1~deb10u1 amd64 [installed,automatic]
libapache2-mod-php/oldstable,now 2:7.3+69 all [installed]
php-apcu-bc/oldstable,now 1.0.4-4 amd64 [installed,automatic]
php-apcu/oldstable,now 5.1.17+4.0.11-1 amd64 [installed]
php-bcmath/oldstable,now 2:7.3+69 all [installed,automatic]
php-bz2/oldstable,now 2:7.3+69 all [installed]
php-cas/oldstable,now 1.3.6-1 all [installed]
php-common/oldstable,now 2:69 all [installed,automatic]
php-curl/oldstable,now 2:7.3+69 all [installed]
php-gd/oldstable,now 2:7.3+69 all [installed,automatic]
php-intl/oldstable,now 2:7.3+69 all [installed]
php-ldap/oldstable,now 2:7.3+69 all [installed,automatic]
php-mbstring/oldstable,now 2:7.3+69 all [installed,automatic]
php-mysql/oldstable,now 2:7.3+69 all [installed]
php-xml/oldstable,now 2:7.3+69 all [installed,automatic]
php-xmlrpc/oldstable,now 2:7.3+69 all [installed]
php-zip/oldstable,now 2:7.3+69 all [installed]
php7.3-bcmath/oldstable,oldstable,now 7.3.31-1~deb10u1 amd64 [installed,automatic]
php7.3-bz2/oldstable,oldstable,now 7.3.31-1~deb10u1 amd64 [installed,automatic]
php7.3-cli/oldstable,oldstable,now 7.3.31-1~deb10u1 amd64 [installed,automatic]
php7.3-common/oldstable,oldstable,now 7.3.31-1~deb10u1 amd64 [installed,automatic]
php7.3-curl/oldstable,oldstable,now 7.3.31-1~deb10u1 amd64 [installed,automatic]
php7.3-gd/oldstable,oldstable,now 7.3.31-1~deb10u1 amd64 [installed,automatic]
php7.3-intl/oldstable,oldstable,now 7.3.31-1~deb10u1 amd64 [installed,automatic]
php7.3-json/oldstable,oldstable,now 7.3.31-1~deb10u1 amd64 [installed,automatic]
php7.3-ldap/oldstable,oldstable,now 7.3.31-1~deb10u1 amd64 [installed,automatic]
php7.3-mbstring/oldstable,oldstable,now 7.3.31-1~deb10u1 amd64 [installed,automatic]
php7.3-mysql/oldstable,oldstable,now 7.3.31-1~deb10u1 amd64 [installed,automatic]
php7.3-opcache/oldstable,oldstable,now 7.3.31-1~deb10u1 amd64 [installed,automatic]
php7.3-readline/oldstable,oldstable,now 7.3.31-1~deb10u1 amd64 [installed,automatic]
php7.3-xml/oldstable,oldstable,now 7.3.31-1~deb10u1 amd64 [installed,automatic]
php7.3-xmlrpc/oldstable,oldstable,now 7.3.31-1~deb10u1 amd64 [installed,automatic]
php7.3-zip/oldstable,oldstable,now 7.3.31-1~deb10u1 amd64 [installed,automatic]
php7.3/oldstable,oldstable,now 7.3.31-1~deb10u1 all [installed,automatic]
php/oldstable,now 2:7.3+69 all [installed]

Немало.

Пакеты PHP 8 для Debian доступны в репозитории deb.susy.org. Устанавливаем необходимые зависимости:

apt install -y lsb-release ca-certificates apt-transport-https software-properties-common

Добавьте APT-репозиторий пакетов PHP на свой сервер Debian:

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

Импортировать ключ репозитория:

wget -qO - https://packages.sury.org/php/apt.gpg | apt-key add -

Выполните обновление индекса пакета, чтобы убедиться, что репозиторий добавлен:

apt update

Fetched 369 kB in 1s (298 kB/s)
Reading package lists… Done
Building dependency tree
Reading state information… Done
45 packages can be upgraded. Run ‘apt list –upgradable’ to see them.

Запускаем обновление пакетов:

apt upgrade -y

Снова проверяем установленные версии PHP:

apt list --installed | grep php

Видим среди прочих остатки старых версий:


php-zip/buster,now 2:8.1+92+0~20220117.43+debian10~1.gbpe0d14e all [installed]
php7.3-bcmath/buster,now 7.3.33-1+0~20211119.91+debian10~1.gbp618351 amd64 [installed,automatic]
php7.3-bz2/buster,now 7.3.33-1+0~20211119.91+debian10~1.gbp618351 amd64 [installed,auto-removable]
php7.3-cli/buster,now 7.3.33-1+0~20211119.91+debian10~1.gbp618351 amd64 [installed,automatic]
php7.3-common/buster,now 7.3.33-1+0~20211119.91+debian10~1.gbp618351 amd64 [installed,automatic]
php7.3-curl/buster,now 7.3.33-1+0~20211119.91+debian10~1.gbp618351 amd64 [installed,auto-removable]
php7.3-gd/buster,now 7.3.33-1+0~20211119.91+debian10~1.gbp618351 amd64 [installed,automatic]
php7.3-intl/buster,now 7.3.33-1+0~20211119.91+debian10~1.gbp618351 amd64 [installed,auto-removable]
php7.3-json/buster,now 7.3.33-1+0~20211119.91+debian10~1.gbp618351 amd64 [installed,automatic]
php7.3-ldap/buster,now 7.3.33-1+0~20211119.91+debian10~1.gbp618351 amd64 [installed,automatic]
php7.3-mbstring/buster,now 7.3.33-1+0~20211119.91+debian10~1.gbp618351 amd64 [installed,automatic]
php7.3-mysql/buster,now 7.3.33-1+0~20211119.91+debian10~1.gbp618351 amd64 [installed,auto-removable]
php7.3-opcache/buster,now 7.3.33-1+0~20211119.91+debian10~1.gbp618351 amd64 [installed,automatic]
php7.3-readline/buster,now 7.3.33-1+0~20211119.91+debian10~1.gbp618351 amd64 [installed,automatic]
php7.3-xml/buster,now 7.3.33-1+0~20211119.91+debian10~1.gbp618351 amd64 [installed,automatic]
php7.3-xmlrpc/buster,now 7.3.33-1+0~20211119.91+debian10~1.gbp618351 amd64 [installed,auto-removable]
php7.3-zip/buster,now 7.3.33-1+0~20211119.91+debian10~1.gbp618351 amd64 [installed,auto-removable]
php7.3/buster,now 7.3.33-1+0~20211119.91+debian10~1.gbp618351 all [installed,automatic]
php7.4-apcu-bc/buster,now 1.0.5-14+0~20211115.22+debian10~1.gbpa00758 amd64 [installed,automatic]
php7.4-apcu/buster,now 5.1.21+4.0.11-7+0~20220117.31+debian10~1.gbp9a887a amd64 [installed,automatic]
php7.4-cli/buster,now 7.4.29-1+0~20220422.62+debian10~1.gbp6939ea amd64 [installed,automatic]
php7.4-common/buster,now 7.4.29-1+0~20220422.62+debian10~1.gbp6939ea amd64 [installed,automatic]
php7.4-json/buster,now 7.4.29-1+0~20220422.62+debian10~1.gbp6939ea amd64 [installed,automatic]
php7.4-opcache/buster,now 7.4.29-1+0~20220422.62+debian10~1.gbp6939ea amd64 [installed,automatic]
php7.4-phpdbg/buster,now 7.4.29-1+0~20220422.62+debian10~1.gbp6939ea amd64 [installed,automatic]
php7.4-readline/buster,now 7.4.29-1+0~20220422.62+debian10~1.gbp6939ea amd64 [installed,automatic]
php8.1-apcu/buster,now 5.1.21+4.0.11-7+0~20220117.31+debian10~1.gbp9a887a amd64 [installed,automatic]
php8.1-bcmath/buster,now 8.1.6-1+0~20220517.17+debian10~1.gbp6b3bd1 amd64 [installed,automatic]

Удалим их:

apt purge -y php7.3-*
apt purge -y php7.4-*

Вот теперь порядок, у нас остались только новые версии PHP и плагинов.

Остается только переключить наш веб сервер Apache на использование новых версий PHP, это делается командами a2enmod и a2dismod:

a2enmod php8.1
Considering dependency mpm_prefork for php8.1:
Considering conflict mpm_event for mpm_prefork:
Considering conflict mpm_worker for mpm_prefork:
Module mpm_prefork already enabled
Considering conflict php5 for php8.1:
Enabling module php8.1.
To activate the new configuration, you need to run:
systemctl restart apache2

Как и написано, перезагружаем службу apache2:

systemctl restart apache2

Оставьте ответ

Ваш адрес email не будет опубликован.

40 ÷ = 20