Amazon Linux2: Upgrade der PHP-Version von 7.4 auf 8.0 für die WordPress-Anwendung

Lesezeit: 3 Minuten

Mahbub Rahmans Benutzeravatar
Mahbub Rahman

Ich habe eine WordPress-Anwendung auf der Amazon Linux 2 EC2-Instanz installiert. Die aktuell installierte PHP-Version ist 7.4. Ich möchte diese Version auf 8.0 aktualisieren

Ich habe die folgenden Befehle im EC2-Terminal ausgeführt, um PHP zu aktualisieren:

$ amazon-linux-extras | grep php

42  php7.4=latest            enabled      [ =stable ]
_  php8.0                   available    [ =stable ]

$ amazon-linux-extras disable php7.4

....
....
42 php7.4 available [ =stable ]
.....
50 selinux-ng available [ =stable ]
51 php8.0 available [ =stable ]
.....
61 dnsmasq2.85 available [ =stable ]
* Extra topic has reached end of support.

$ amazon-linux-extras | grep php

42 php7.4 available [ =stable ]
51 php8.0 available [ =stable ]

$ amazon-linux-extras enable php8.0

....
42 _ php7.4 available [ =stable ]
....
51 php8.0=latest enabled [ =stable ]
.....
Now you can install:
# yum clean metadata
# yum install php-cli php-pdo php-fpm php-mysqlnd

$ yum clean metadata

Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
Cleaning repos: amzn2-core amzn2extra-docker amzn2extra-nginx1.12 amzn2extra-php8.0 mysql-connectors-community mysql-tools-community
: mysql80-community
21 metadata files removed
12 sqlite files removed
0 metadata files removed

$ yum info php

51 packages excluded due to repository priority protections
Available Packages
Name : php
Arch : x86_64
Version : 8.0.16
Release : 1.amzn2
Size : 3.3 M
Repo : amzn2extra-php8.0/2/x86_64

$ php -v

**PHP 7.4.28** (cli) (built: Feb 28 2022 23:38:08) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.28, Copyright (c), by Zend Technologies

$ yum install php-cli php-pdo php-fpm php-mysqlnd

--> Finished Dependency Resolution
Error: Package: php-json-7.4.28-1.amzn2.x86_64 (@amzn2extra-php7.4)
           Requires: php-common(x86-64) = 7.4.28-1.amzn2
           Removing: php-common-7.4.28-1.amzn2.x86_64 (@amzn2extra-php7.4)
               php-common(x86-64) = 7.4.28-1.amzn2
           Updated By: php-common-8.0.16-1.amzn2.x86_64 (amzn2extra-php8.0)
               php-common(x86-64) = 8.0.16-1.amzn2
           Available: php-common-5.4.16-43.amzn2.x86_64 (amzn2-core)
               php-common(x86-64) = 5.4.16-43.amzn2
           Available: php-common-5.4.16-43.amzn2.0.1.x86_64 (amzn2-core)
               php-common(x86-64) = 5.4.16-43.amzn2.0.1
           Available: php-common-5.4.16-43.amzn2.0.2.x86_64 (amzn2-core)
               php-common(x86-64) = 5.4.16-43.amzn2.0.2
           Available: php-common-5.4.16-43.amzn2.0.3.x86_64 (amzn2-core)
               php-common(x86-64) = 5.4.16-43.amzn2.0.3
           Available: php-common-5.4.16-43.amzn2.0.4.x86_64 (amzn2-core)
               php-common(x86-64) = 5.4.16-43.amzn2.0.4
           Available: php-common-5.4.16-45.amzn2.0.5.x86_64 (amzn2-core)
               php-common(x86-64) = 5.4.16-45.amzn2.0.5
           Available: php-common-5.4.16-45.amzn2.0.6.x86_64 (amzn2-core)
               php-common(x86-64) = 5.4.16-45.amzn2.0.6
           Available: php-common-5.4.16-46.amzn2.0.2.x86_64 (amzn2-core)
               php-common(x86-64) = 5.4.16-46.amzn2.0.2
           Available: php-common-8.0.0-2.amzn2.x86_64 (amzn2extra-php8.0)
               php-common(x86-64) = 8.0.0-2.amzn2
           Available: php-common-8.0.2-1.amzn2.x86_64 (amzn2extra-php8.0)
               php-common(x86-64) = 8.0.2-1.amzn2
           Available: php-common-8.0.6-1.amzn2.x86_64 (amzn2extra-php8.0)
               php-common(x86-64) = 8.0.6-1.amzn2
           Available: php-common-8.0.8-1.amzn2.x86_64 (amzn2extra-php8.0)
               php-common(x86-64) = 8.0.8-1.amzn2
           Available: php-common-8.0.13-1.amzn2.x86_64 (amzn2extra-php8.0)
               php-common(x86-64) = 8.0.13-1.amzn2
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

Aus der Ausgabe geht hervor, dass die obige Installation fehlgeschlagen ist. Ich habe den obigen Befehl mit ausprobiert –skip-broken sowie. Aber die Ausgabe ist dieselbe.

Aufgrund der Ausgabe dachte ich, dass das Problem beim PHP-JSON-Paket liegt. Also habe ich versucht, das PHP-JSON-Paket zu entfernen:

$ yum -y remove php-json-7.4.28-1.amzn2.x86_64

Removed:
  php-json.x86_64 0:7.4.28-1.amzn2

Dependency Removed:
  php-cli.x86_64 0:7.4.28-1.amzn2             php-common.x86_64 0:7.4.28-1.amzn2           php-fpm.x86_64 0:7.4.28-1.amzn2
  php-gd.x86_64 0:7.4.28-1.amzn2              php-mbstring.x86_64 0:7.4.28-1.amzn2         php-mysqlnd.x86_64 0:7.4.28-1.amzn2
  php-opcache.x86_64 0:7.4.28-1.amzn2         php-pdo.x86_64 0:7.4.28-1.amzn2              php-xml.x86_64 0:7.4.28-1.amzn2

Complete!

Ich habe erneut versucht, die gleichen Pakete wie unten zu installieren:

$ yum install php-cli php-pdo php-fpm php-mysqlnd

.....
Installed:
  php.x86_64 0:8.0.16-1.amzn2

Dependency Installed:
  apr.x86_64 0:1.7.0-9.amzn2   apr-util.x86_64 0:1.6.1-5.amzn2.0.2  ....
.... .... .....
$ systemctl restart nginx
$ systemctl restart php-fpm.service

Jetzt habe ich versucht, auf die Website zuzugreifen, und der Browser zeigt HTTP 502 ERROR an. Wo habe ich einen Fehler gemacht?

Als Referenz habe ich die folgenden Links verwendet, um das Upgrade durchzuführen:

  1. https://computingforgeeks.com/how-to-install-php-8-on-amazon-linux/
  2. https://www.cyberciti.biz/faq/install-php-7-2-7-3-7-4-0r-8-0-on-amazon-linux-2/
  3. https://omkz.net/en-ec2-php8-laravel8/

  • Was sagen Ihre FPM-Protokolle? Kann PHP-FPM nicht gestartet werden?

    – Jordanien

    18. Mai 2022 um 16:17 Uhr

  • Nach der Installation von php-cli php-pdo php-fpm php-mysqlnd Beim Neustart von php-fpm gab es keine Beschwerden

    – Mahbub Rahman

    18. Mai 2022 um 23:46 Uhr

  • Ich hatte das gleiche Problem und musste es entfernen php-json hat das Problem gelöst. Ich wollte nur darauf hinweisen, dass die AWS-Meldung deshalb angezeigt wird, weil die JSON-Erweiterung ab PHP8 nicht mehr existiert, und zwar jetzt immer im PHP-Kern enthalten.

    – AdHorger

    12. August 2022 um 19:54 Uhr


1451240cookie-checkAmazon Linux2: Upgrade der PHP-Version von 7.4 auf 8.0 für die WordPress-Anwendung

This website is using cookies to improve the user-friendliness. You agree by using the website further.

Privacy policy