PHP Upgraden zu PHP 8.2

Aus Triopsi Hosting Wiki
Version vom 26. Dezember 2022, 11:21 Uhr von Triopsi (Diskussion | Beiträge)
(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)
Zur Navigation springen Zur Suche springen

Um PHP aktualsieren braucht man nicht viel. Los Geht's

Zunächst holen wir uns alle aktuell installierten PHP Module. Diese speichern wir in eine Textdatei. Mithilfe dieser Auflistung wissen wir, welche Module wir nachher nachinstallieren müssen.

dpkg -l | grep php | tee php-module.txt

Hier ein Beispiel:

ii  php-common                        2:93+0~20221211.45+debian10~1.gbpdb4dcc            all          Common files for PHP packages
ii  php7.4-apcu                       5.1.22+4.0.11-2+0~20221209.34+debian10~1.gbp2b07cb amd64        APC User Cache for PHP
rc  php7.4-apcu-bc                    1.0.5-14+0~20221210.24+debian10~1.gbpa00758        amd64        APCu Backwards Compatibility Module
ii  php7.4-bcmath                     1:7.4.33-1+0~20221108.73+debian10~1.gbpa0035a      amd64        Bcmath module for PHP
ii  php7.4-bz2                        1:7.4.33-1+0~20221108.73+debian10~1.gbpa0035a      amd64        bzip2 module for PHP
ii  php7.4-cli                        1:7.4.33-1+0~20221108.73+debian10~1.gbpa0035a      amd64        command-line interpreter for the PHP scripting language
ii  php7.4-common                     1:7.4.33-1+0~20221108.73+debian10~1.gbpa0035a      amd64        documentation, examples and common module for PHP
ii  php7.4-curl                       1:7.4.33-1+0~20221108.73+debian10~1.gbpa0035a      amd64        CURL module for PHP
ii  php7.4-fpm                        1:7.4.33-1+0~20221108.73+debian10~1.gbpa0035a      amd64        server-side, HTML-embedded scripting language (FPM-CGI binary)
ii  php7.4-gd                         1:7.4.33-1+0~20221108.73+debian10~1.gbpa0035a      amd64        GD module for PHP
ii  php7.4-gmp                        1:7.4.33-1+0~20221108.73+debian10~1.gbpa0035a      amd64        GMP module for PHP
ii  php7.4-igbinary                   3.2.12+2.0.8-2+0~20221210.36+debian10~1.gbp293257  amd64        igbinary PHP serializer
ii  php7.4-imagick                    3.7.0-3+0~20221209.38+debian10~1.gbp8a8977         amd64        Provides a wrapper to the ImageMagick library
ii  php7.4-intl                       1:7.4.33-1+0~20221108.73+debian10~1.gbpa0035a      amd64        Internationalisation module for PHP
ii  php7.4-json                       1:7.4.33-1+0~20221108.73+debian10~1.gbpa0035a      amd64        JSON module for PHP
ii  php7.4-mbstring                   1:7.4.33-1+0~20221108.73+debian10~1.gbpa0035a      amd64        MBSTRING module for PHP
ii  php7.4-mysql                      1:7.4.33-1+0~20221108.73+debian10~1.gbpa0035a      amd64        MySQL module for PHP
ii  php7.4-opcache                    1:7.4.33-1+0~20221108.73+debian10~1.gbpa0035a      amd64        Zend OpCache module for PHP
ii  php7.4-readline                   1:7.4.33-1+0~20221108.73+debian10~1.gbpa0035a      amd64        readline module for PHP
ii  php7.4-redis                      5.3.7+4.3.0-2+0~20221210.45+debian10~1.gbp99917f   amd64        PHP extension for interfacing with Redis
ii  php7.4-xml                        1:7.4.33-1+0~20221108.73+debian10~1.gbpa0035a      amd64        DOM, SimpleXML, XML, and XSL module for PHP
ii  php7.4-zip                        1:7.4.33-1+0~20221108.73+debian10~1.gbpa0035a      amd64        Zip module for PHP

System updaten

Wir aktualisieren unser System und holen uns die entsprechenden Repositorys für den Upgrade.

sudo apt update && sudo apt upgrade -y

Wir installieren noch die nötigen Abhänhigkeiten und Zertifikate.

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

Wir fügen nun die Repository von Ondrej Surys hinzu und aktualisieren unserer Paketquelle.

sudo curl -sSL https://packages.sury.org/php/README.txt | sudo bash -x
sudo apt update

Alte PHP Version deinstallieren

Um später keien php leichen zu haben deinstallieren wir das alte PHP 7.x.

sudo apt-get purge php7.*

Wir löschen alle cahe und entfernen die alten abhänhigkeiten.

sudo apt-get autoclean && sudo apt-get autoremove

PHP 8.2 installieren

Nun können wir die PHP verion installieren.

sudo apt-get install php8.2

Das wars!

Wir haben nun erfolgreich PHP 8.2 in der grundform installiert. Jedoch fehlen nun die ensprechenden Module. Diese könenn wir nun anhand der vorher erstellen PHP-Module Liste nach installieren.

apt install php8.2-apcu php8.2-zip php8.2-xml php8.2-redis php8.2-readline php8.2-opcache php8.2-mysql php8.2-mbstring php8.2-common php8.2-cli php8.2-bz2 php8.2-bcmath php8.2-gd php8.2-intl php8.2-imagick php8.2-igbinary php8.2-gmp

PHP 8.2 für Apache installieren

Für den Apache gibt es das libapache2-mod-php8.2 Module. Diese könenn wir nun installieren.

sudo apt install php8.2 libapache2-mod-php8.2

Nach der installation benöten wir noch ein restart von unserem Apache Dienst.

sudo systemctl restart apache2

PHP 8.2 FPM installieren

Für das FPM Modul müssen wir nur folgendes tuen:

sudo apt install php8.2-fpm libapache2-mod-fcgid

Wir aktivieren das Modul im Apache und starten ihn neu.

sudo a2enmod proxy_fcgi setenvif && sudo a2enconf php8.2-fpm
sudo systemctl restart apache2

PHP 8.2 für den NGINX

Ähnlich für den NGINX Dienst.

sudo apt install php8.2 php8.2-fpm php8.2-cli

Danach starten wir den NGINX Dienst neu.

sudo systemctl restart nginx

Version prüfen

Um die PHP Version zu prüfen, genügt es foglednes in die Komandozeile einzutippen.

php --version

Output:

PHP 8.2.0 (cli) (built: Dec  8 2022 15:03:53) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.0, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.0, Copyright (c), by Zend Technologies