Article #6
Mettre à jour le système
apt update && apt upgrade
Installer Apache 2
apt install apache2
Installer PHP 8.1 sur Debian 11/10/9
Install required temporary packages
sudo apt install -y lsb-release ca-certificates apt-transport-https software-properties-common gnupg2 Add Surý Debian PPA repository to your Debian system echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/sury-php.list
Import packages signing GPG key;
curl -fsSL https://packages.sury.org/php/apt.gpg| sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/sury-keyring.gpg
Confirm if the repository is working by downloading package information from all configured sources:
$ sudo apt update
Résultat:
Hit:1 http://security.debian.org/debian-security bullseye-security InRelease
Hit:2 http://deb.debian.org/debian bullseye InRelease
Hit:3 http://deb.debian.org/debian bullseye-updates InRelease
Hit:4 http://deb.debian.org/debian bullseye-backports InRelease
Hit:5 https://packages.sury.org/php bullseye InRelease
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to date.
Installer PHP 8.1
sudo apt update sudo apt install php8.1
Résultat:
....
Reading state information... Done
The following additional packages will be installed:
apache2 apache2-bin apache2-data apache2-utils bzip2 libapache2-mod-php8.1 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libgdbm-compat4 libjansson4
liblua5.3-0 libperl5.32
libsodium23 mailcap mime-support perl perl-modules-5.32 php-common php8.1-cli php8.1-common php8.1-opcache php8.1-readline ssl-cert
Suggested packages:
apache2-doc apache2-suexec-pristine | apache2-suexec-custom www-browser bzip2-doc php-pear perl-doc libterm-readline-gnu-perl | libterm-readline-perl-perl make
harness-archive-perl
The following NEW packages will be installed:
apache2 apache2-bin apache2-data apache2-utils bzip2 libapache2-mod-php8.1 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libgdbm-compat4 libjansson4
liblua5.3-0 libperl5.32
libsodium23 mailcap mime-support perl perl-modules-5.32 php-common php8.1 php8.1-cli php8.1-common php8.1-opcache php8.1-readline ssl-cert
0 upgraded, 26 newly installed, 0 to remove and 0 not upgraded.
Need to get 14.3 MB of archives.
After this operation, 77.2 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Installed version of PHP can be checked with the command below after a successful installation
$ php -v
Résultat:
PHP 8.1.9 (cli) (built: Aug 15 2022 09:47:52) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.9, Copyright (c) Zend Technologies
with Zend OPcache v8.1.9, Copyright (c), by Zend Technologies
Installer PHP 8.1 Extensions sur Debian 11/10/9
PHP 8.1 modules can be installed as packages using below command syntax:
sudo apt install php8.1-
Où:
$ sudo apt install php8.1-mysql
Résultat:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
php8.1-mysql
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 116 kB of archives.
After this operation, 466 kB of additional disk space will be used.
Get:1 https://packages.sury.org/php bullseye/main amd64 php8.1-mysql amd64 8.1.0~rc6-3+0~20211120.8+debian11~1.gbp2227b0 [116 kB]
Fetched 116 kB in 0s (1152 kB/s)
Selecting previously unselected package php8.1-mysql.
(Reading database ... 37704 files and directories currently installed.)
Preparing to unpack .../php8.1-mysql_8.1.9-1+0~20220815.24+debian11~1.gbp4d5b5a_amd64.deb ...
Unpacking php8.1-mysql (8.1.9-1+0~20220815.24+debian11~1.gbp4d5b5a) ...
Setting up php8.1-mysql (8.1.9-1+0~20220815.24+debian11~1.gbp4d5b5a) ...
Creating config file /etc/php/8.1/mods-available/mysqlnd.ini with new version
Creating config file /etc/php/8.1/mods-available/mysqli.ini with new version
Creating config file /etc/php/8.1/mods-available/pdo_mysql.ini with new version
Processing triggers for libapache2-mod-php8.1 (8.1.9-1+0~20220815.24+debian11~1.gbp4d5b5a) ...
Processing triggers for php8.1-cli (8.1.9-1+0~20220815.24+debian11~1.gbp4d5b5a) ...
Pour installer toutes les extensions PHP couramment utilisées, exécutez les commandes suivantes en tant qu'utilisateur disposant des privilèges sudo
$ sudo apt install php8.1-{bcmath,fpm,xml,mysql,zip,intl,ldap,gd,cli,bz2,curl,mbstring,pgsql,opcache,soap,cgi}
Poursuivez l'installation :
...
suggested packages:
libgd-tools php-pear
The following NEW packages will be installed:
fontconfig-config fonts-dejavu-core libdeflate0 libfontconfig1 libgd3 libjbig0 libjpeg62-turbo libonig5 libpq5 libtiff5 libwebp6 libx11-6 libx11-data libxau6 libxcb1 libxdmcp6
>libxpm4 libxslt1.1
libzip4 php8.1-bcmath php8.1-bz2 php8.1-cgi php8.1-curl php8.1-gd php8.1-intl php8.1-ldap php8.1-mbstring php8.1-pgsql php8.1-soap php8.1-xml php8.1-zip
0 upgraded, 31 newly installed, 0 to remove and 0 not upgraded.
Need to get 7150 kB of archives.
After this operation, 26.5 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Vérifiez les modules PHP chargés à l'aide de la commande ;
$ php --modules
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
dom
exif
FFI
fileinfo
filter
ftp
gd
gettext
hash
iconv
intl
json
ldap
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_pgsql
pgsql
Phar
posix
readline
Reflection
session
shmop
SimpleXML
soap
sockets
sodium
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib