Update auf aktuelle PHP Version

Um mein Serverle nach über einem Jahr habe ich Nextcloud schrittweise von Ver. 18 auf 20 angehoben.

Danach gab es in der Übersicht unter anderem folgende Warnungen:

  • Nextcloud 20 ist die letzte Version, die PHP 7.2 unterstützt. Nextcloud 21 benötigt mindestens PHP 7.3.

Danach habe ich den Rechner von Ubuntu 18.04 auf Ubuntu 20.04.2 LTS upgedated.
Die Warnungen waren danach exakt die selben.
Eine Eingabe des Befehls:
apt list --installed | grep php
auf der Kommandozeile ergab folgende Ausgabe:

php-apcu-bc/now 1.0.5-13+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]
php-apcu/now 5.1.20+4.0.11-1+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]
php-common/now 2:84+ubuntu18.04.1+deb.sury.org+1 all  [Installiert,lokal]
php-igbinary/now 3.2.1+2.0.8-6+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]
php-imagick/now 3.4.4+php8.0+3.4.4-7+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]
php-redis/now 5.3.4+4.3.0-1+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]
php-smbclient/now 1.0.6-1+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]
php5.6-common/now 5.6.40-52+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]
php5.6-igbinary/now 3.2.1+2.0.8-6+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]
php7.0-apcu-bc/now 1.0.5-13+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]
php7.0-apcu/now 5.1.20+4.0.11-1+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]
php7.0-common/now 7.0.33-52+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]
php7.0-igbinary/now 3.2.1+2.0.8-6+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]
php7.1-apcu-bc/now 1.0.5-13+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]
php7.1-apcu/now 5.1.20+4.0.11-1+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]
php7.1-common/now 7.1.33-39+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]
php7.1-igbinary/now 3.2.1+2.0.8-6+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]
php7.2-apcu-bc/now 1.0.5-13+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]
php7.2-apcu/now 5.1.20+4.0.11-1+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]
php7.2-bz2/now 7.2.34-23+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]
php7.2-cli/now 7.2.34-23+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]
php7.2-common/now 7.2.34-23+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]
php7.2-curl/now 7.2.34-23+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]
php7.2-fpm/now 7.2.34-23+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]
php7.2-gd/now 7.2.34-23+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]
php7.2-igbinary/now 3.2.1+2.0.8-6+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]
php7.2-intl/now 7.2.34-23+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]
php7.2-json/now 7.2.34-23+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]
php7.2-ldap/now 7.2.34-23+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]
php7.2-mbstring/now 7.2.34-23+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]
php7.2-mysql/now 7.2.34-23+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]
php7.2-opcache/now 7.2.34-23+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]
php7.2-readline/now 7.2.34-23+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]
php7.2-xml/now 7.2.34-23+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]
php7.2-zip/now 7.2.34-23+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]
php7.3-apcu-bc/now 1.0.5-13+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]
php7.3-apcu/now 5.1.20+4.0.11-1+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]
php7.3-common/now 7.3.29-1+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]
php7.3-igbinary/now 3.2.1+2.0.8-6+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]
php7.4-apcu-bc/now 1.0.5-13+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]
php7.4-apcu/now 5.1.20+4.0.11-1+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]
php7.4-common/now 7.4.21-1+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]
php7.4-igbinary/now 3.2.1+2.0.8-6+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]
php8.0-apcu/now 5.1.20+4.0.11-1+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]
php8.0-common/now 8.0.8-1+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]
php8.0-igbinary/now 3.2.1+2.0.8-6+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]
php8.0-imagick/now 3.4.4+php8.0+3.4.4-7+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]
php8.0-redis/now 5.3.4+4.3.0-1+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]
php8.0-smbclient/now 1.0.6-1+ubuntu18.04.1+deb.sury.org+1 amd64  [Installiert,lokal]

Die Versionsabfrage von PHP ergibt folgendes:

xxx@xxxxxxx:~$ php -v
PHP 7.2.34-23+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Jul  1 2021 16:06:47) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.34-23+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
  • Was für ein Server? kleiner lokaler Rechner im Wohnzimmer
  • Hardware PC Intel I5 NUC
  • Betriebssystem Ubuntu 20.04.2 LTS
  • Nextcloud Version: 20.0.11
  • PHP Version: Dies ist mein Problem
  • Datenbank: Nginx

Ich hoffe auf einfache Lösungen, da meine EDV-Kenntnisse doch sehr profan sind.
Vielen Dank im voraus

Um PHP auf dem Ubuntu 20.04-Server auf die Version 7.4 zu upgraden, gehe am besten wie folgt vor:

  1. Logge Dich in die CLI ein (command line inteface).
  2. Füge das Repository für PHP 7.4 der sources.list hinzu:
$ sudo apt install software-properties-common
$ sudo add-apt-repository ppa:ondrej/php
$ sudo apt update
  1. Prüfe nun, welche PHP-Module aktuell installiert und aktiv sind. Am besten Du notierst Dir die Ausgabe des Befehls:
    $ sudo dpkg --get-selections | grep -v deinstall | grep php

  2. Zur Installation von PHP 7.4 gehe nun wie folgt vor:
    $ sudo apt install -y php7.4

  3. Prüfe nun, ob die Installation von PHP 7.4.x erfolgreich war:
    $ php -v

  4. Nun installierst Du die PHP-Module für die Version PHP 7.4.x, und zwar basierend auf der Ausgabe/Liste in Punkt 3, z.B:
    $ sudo apt install php7.4-mysql php7.4-curl php7.4-json php7.4-cgi php7.4-xsl
    (das obige ist nur als Beispiel gedacht. Ersetze die benötigten Module mit den Modulen aus den Notizen in Punkt 3 (s.o.)

Wenn die Installation von PHP 7.4.x geklappt hat kannst Du mit dem Befehl:
$ sudo update-alternatives --config php
nun die neu installierte Version z.B. für Deine Nextcloud als Standardversion auswählen.

Da ich die letzten Tage nicht im Haus war kam ich erst heute dazu Ihren Vorschlag umzusetzen.

Alle die Steps wurden von mir angearbeitet.
Allerdings muss ich irgendwo einen fatalen Fehler begangen haben, denn ich erreiche meine Nextcloud nun weder local noch extern.
Ich vermute dass bei den Upgrades eine Option von mir leichtsinnig bestätigt wurde.

Es scheint das der apache2 webserver anstatt des nginx aktiviert wurde.
Ich bin mit aber nicht sicher.
Die Ausgabe des Befehls:

xxx@oigeneklaud:~$ systemctl status nginx.service
● nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Tue 2021-08-03 13:33:44 CEST; 24min ago
       Docs: man:nginx(8)
    Process: 3418 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)

Aug 03 13:33:44 oigeneklaud systemd[1]: Starting A high performance web server and a reverse proxy server...
Aug 03 13:33:44 oigeneklaud nginx[3418]: nginx: [emerg] unknown log format "main" in /etc/nginx/conf.d/letsencrypt.conf:5
Aug 03 13:33:44 oigeneklaud nginx[3418]: nginx: configuration file /etc/nginx/nginx.conf test failed
Aug 03 13:33:44 oigeneklaud systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
Aug 03 13:33:44 oigeneklaud systemd[1]: nginx.service: Failed with result 'exit-code'.
Aug 03 13:33:44 oigeneklaud systemd[1]: Failed to start A high performance web server and a reverse proxy server.
xxx@oigeneklaud:~$ 

Ausgabe bei apache2:

roland@oigeneklaud:~$ systemctl status apache2.service
● apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2021-08-03 13:29:08 CEST; 39min ago
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 749 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
   Main PID: 808 (apache2)
      Tasks: 6 (limit: 9399)
     Memory: 20.6M
     CGroup: /system.slice/apache2.service
             ├─808 /usr/sbin/apache2 -k start
             ├─869 /usr/sbin/apache2 -k start
             ├─870 /usr/sbin/apache2 -k start
             ├─871 /usr/sbin/apache2 -k start
             ├─872 /usr/sbin/apache2 -k start
             └─873 /usr/sbin/apache2 -k start

Aug 03 13:29:08 oigeneklaud systemd[1]: Starting The Apache HTTP Server...
Aug 03 13:29:08 oigeneklaud apachectl[775]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName'>
Aug 03 13:29:08 oigeneklaud systemd[1]: Started The Apache HTTP Server.

Falls dies der Fehler sein sollte:
Kann man dies mit einfachen Möglichkeiten wieder auf nginx zurücksetzen?