Projekt

Allgemein

Profil

Install PHP8 on Debian 10 Debian 11 » Historie » Version 1

Martin Meier, 03.02.2023 11:32

1 1 Martin Meier
h1. Install PHP8 on Debian 10  Debian 11
2
3
Based on "linuxshelltips":https://www.linuxshelltips.com/install-php-8-debian/ but using key only for sury library.
4
5
Current best practice is not to install keys for extra repositories as general apt keys but storing them in /usr/share/keyring and authorizing repositories explicitly with the corresponding key.
6
7
Also there's no need to uninstall PHP 7. several PHP versions can coexist.
8
9
So, let's start.
10
11
Have your Debian up to date:
12
<pre><code class="shell">
13
sudo apt update && sudo apt upgrade -y
14
</code></pre>
15
16
Next, install the required PHP 8 installation dependencies and also configure the UFT-8 Unicode standard.
17
<pre><code class="shell">
18
sudo apt install -y lsb-release ca-certificates apt-transport-https software-properties-common gnupg2   
19
sudo locale-gen en_US.UTF-8
20
</code></pre>
21
22
Get and store Sury's keys:
23
<pre><code class="shell">
24
wget -qO - https://packages.sury.org/php/apt.gpg|gpg --dearmor | sudo tee /usr/share/keyrings/sury-php.gpg > /dev/null
25
</code></pre>
26
27
Config Sury's repository:
28
<pre><code class="shell">
29
echo "deb [signed-by=/usr/share/keyrings/sury-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/sury-php.list
30
</code></pre>
31
32
Use the newly installed repository (most times it also upgrades the currently installed PHP 7.4):
33
<pre><code class="shell">
34
sudo apt update && sudo apt upgrade -y
35
</code></pre>
36
If the meta packege _php_ is installed, this upgrade switches to the most current PHP version (i.e 8.2 in February 2023)
37
38
Now you can install any supported PHP version:
39
<pre><code class="shell">
40
sudo apt install php8.1
41
</code></pre>
42
43
To install other PHP extensions, reference the syntax:
44
<pre><code class="shell">
45
sudo apt install php8.1-name_of_extension
46
</code></pre>
47
48
For instance, to install a php-fpm extension, we will execute the command:
49
<pre><code class="shell">
50
sudo apt install php8.1-fpm 
51
</code></pre>