Amazon Linux 2023, Amazon Linux 2 and Amazon Linux containers
How to update PHP on Amazon Linux 2023
On Amazon Linux 2023, PHP2Shell is fixed in the php8.2, php8.3, php8.4 and php8.5 packages of release 2023.12.20261021, and php8.1 gets no fix. Each server stays locked to the release it was built from, so a plain dnf update can miss the patch. Move to the new release, restart php-fpm, then confirm the version.
Last reviewed against the Amazon Linux Security Center, the AL2023 user guide, AWS security bulletin 2026-143-AWS and php.net.
Amazon Linux Security Center, 27 October 2026
The ALAS advisories for PHP2Shell
Amazon rebuilt each supported AL2023 branch on the PHP project's fixed release, so the upstream numbers apply directly: php8.4 went to 8.4.27, for instance. The four AL2023 advisories were released on 22 October 2026 and all cover both CVEs. Release 2023.12.20261021 is the first repository version that contains them.
AWS's bulletin
Security bulletin 2026-143-AWS, published on 21 October 2026 and last updated on 23 October, tells customers running PHP on Amazon Linux to apply the updated packages and points to the Security Center for details. It says AWS's own services are not affected, though customer workloads on some of them can be.
| Release | Package | Fixed in | Advisory |
|---|---|---|---|
| Amazon Linux 2023 | php8.5 | 8.5.12-1.amzn2023.0.1 | ALAS2023-2026-3304 |
| Amazon Linux 2023 | php8.4 | 8.4.27-1.amzn2023.0.1 | ALAS2023-2026-3303 |
| Amazon Linux 2023 | php8.3 | 8.3.36-1.amzn2023.0.1 | ALAS2023-2026-3302 |
| Amazon Linux 2023 | php8.2 | 8.2.35-1.amzn2023.0.1 | ALAS2023-2026-3301 |
| Amazon Linux 2023 | php8.1 | No fix planned | None |
| Amazon Linux 2 (php8.2 extra) | php | 8.2.35-1.amzn2.0.1 | ALAS2PHP8.2-2026-015 |
| Amazon Linux 2 (core) | php | No fix planned | None |
| Amazon Linux 2027 Preview | php8.5 | 8.5.12-1.amzn2027.0.1 | ALAS2027-2026-243 |
-
The version applies to every subpackage of a branch, such as
php8.4-fpm,php8.4-cliandphp8.4-mysqlnd, on both x86_64 and aarch64. - Amazon's changelog entries for these builds say only that the package was updated to the new PHP release, so check the version rather than searching the changelog for CVE IDs.
Primary sources: Amazon's CVE-2026-109618 page, CVE-2026-109619 page, ALAS2023-2026-3303 and bulletin 2026-143-AWS. The PHP project's own fixed releases are summarised in PHP2Shell explained.
Five dnf steps
Patch PHP on an AL2023 instance
Run these on the instance itself. For images and containers, the same fix goes into the build instead: see container images.
-
Find your branch and your release
# The PHP branch on this machine (php8.1 to php8.5) rpm -qa 'php8*' | sort # The Amazon Linux release dnf is locked to rpm -q system-release --qf "%{VERSION}\n"A release number lower than 2023.12.20261021 usually means the fixed packages are not visible to dnf yet. A php8.1 package list means no update will help: go to leaving php8.1.
-
Look past your current release
# Releases newer than the one you are locked to sudo dnf check-release-update # PHP advisories in the newest release that apply to this machine dnf updateinfo --releasever=latest --list | grep phpThe first command prints every newer release with the command to reach it. The second should list ALAS2023-2026-3301, 3302, 3303 or 3304 against your PHP packages. If it lists none and the branch is not php8.1, the machine already has the fix.
-
Move to the fixed release
# Move the whole system to the release with the fix, or any later one sudo dnf upgrade --releasever=2023.12.20261021 # Or go straight to the newest release sudo dnf upgrade --releasever=latestAWS recommends taking every update in a new release, which leaves the machine with the same packages as a freshly launched AMI. dnf lists the changes and asks before it applies them, and afterwards the new release becomes the default for every later dnf command. Amazon's advisories also give a narrower command that updates only the PHP packages:
# PHP 8.4 shown; use 3301 for php8.2, 3302 for php8.3, 3304 for php8.5 sudo dnf update --advisory ALAS2023-2026-3303 --releasever 2023.12.20261021That route leaves the machine locked to its old release, and AWS warns that later installs can then fail on dependencies the old release cannot satisfy. Treat it as a stopgap and move the whole system soon after.
-
Restart php-fpm, and Apache if it runs mod_php
sudo systemctl restart php-fpm sudo systemctl restart httpd # if Apache loads PHP through php8.x-modphpEvery php8.x branch uses the same
php-fpmservice name, and its package also drops PHP-FPM configuration into Apache and nginx. On php8.3 and later, mod_php is a separatephp8.x-modphppackage; if it is installed, Apache can run PHP inside its own processes, so restart Apache as well. The PHP-FPM guide explains why workers have to be replaced, not reloaded. -
Check the version that is running
rpm -q php8.4-fpm php8.4-cli php -v systemctl status php-fpmThe package should read 8.4.27-1.amzn2023.0.1 or later (or the matching row of the table for your branch), and
systemctl statusshould show php-fpm starting after the update finished.
How Amazon Linux packages PHP
Branches, releases and images
AL2023 left PHP 7 and 5 out entirely, because the PHP project had already stopped supporting them when it launched. What a machine can run depends on which Amazon Linux it is, and for containers, on which image the build started from.
Amazon Linux 2023: php8.1 to php8.5
Each branch is its own family of php8.x packages, and the families conflict, so a machine holds one branch at a time. All of them share one php-fpm service, /etc/php.ini and /etc/php-fpm.d. AWS supports a branch for as long as the PHP project does, up to AL2023's own end in June 2029.
php8.1: no fix planned
Amazon's support statement put php8.1 at end of support on 31 December 2025, the PHP project's own date, with 8.1.34-1.amzn2023.0.1 as its last build. The Security Center marks both CVEs No Fix Planned for it, so the only remedy is a newer branch.
Amazon Linux 2
AWS's FAQ says AL2 reached end of support on 30 June 2026. The Security Center still shows a fix for the php8.2 extra, issued on 22 October 2026, while the php package in AL2's core repository is No Fix Planned. No other PHP extra is listed against these CVEs.
Amazon Linux container images
AWS publishes AL2023 base and minimal images on Amazon ECR Public, tagged by release. Neither image includes PHP: it arrives through the dnf install in your build, from the repository version of the image you start from.
Versioned repositories
Why the fix can sit unseen
AWS calls this feature deterministic upgrades, and it is on by default. Every AL2023 release is a frozen snapshot of the repositories. An instance launched from an AMI keeps using that AMI's snapshot until someone moves it on, so two instances built from the same image install identical packages.
- The lock lives in one package.
The installed version of
system-releasesets dnf's release variable, which is why step 1 reads it. - Old releases never change. Once a release is published it is immutable, so new and revised advisories only ever appear in later releases.
- dnf check-update looks inward.
Without
--releaseverit only checks the locked release and stays silent about later ones. - Hearing about new releases. AWS
publishes each one in the AL2023 release notes and to the SNS
topic
arn:aws:sns:us-east-1:137112412989:amazon-linux-2023-ami-updates, and dnf warns about newer releases when it installs, updates or removes packages.
Optional: restart services after every update
Amazon Linux offers a smart-restart
package. Once installed, it restarts affected systemd services
whenever dnf updates, upgrades or downgrades packages, and leaves a
reboot hint at /run/smart-restart/reboot-hint-marker
when a reboot is advised. Services listed in a
-denylist file under
/etc/smart-restart-conf.d/ are left
alone.
sudo dnf install smart-restart php8.1 and Amazon Linux 2
Leaving php8.1, the branch with no fix
AWS's own LAMP tutorial for AL2023 still describes PHP 8.1 as the version it installs, so servers set up by following it may still run php8.1. Because the php8.x families conflict, the change is a remove and reinstall rather than an upgrade.
# Amazon's support status for the branch
dnf supportinfo --pkg php8.1-fpm
# Bring everything else up to date first
sudo dnf upgrade --releasever=latest
# Record the php8.1 packages and copy the shared configuration
rpm -qa 'php8.1*' | sort > ~/php8.1-packages.txt
sudo mkdir -p /root/php8.1-config
sudo cp -a /etc/php.ini /etc/php.d /etc/php-fpm.conf /etc/php-fpm.d /root/php8.1-config/
# Swap branches and start PHP-FPM on the new one
sudo dnf remove 'php8.1*'
sudo dnf install php8.4 php8.4-fpm php8.4-mysqlnd
sudo systemctl enable --now php-fpm dnf shows every package it will remove and waits for confirmation, so read the list before agreeing; reinstall any extensions from your saved list under their php8.4 names. AWS's PHP page links the PHP project's migration notes for each step from 8.1 to 8.5. If the change cannot happen before the server is next exposed, apply the interim settings and weigh taking the site offline.
Amazon Linux 2
On AL2, current PHP branches come from amazon-linux-extras topics. Only the php8.2 topic has a fix; the php package in AL2's core repository has none. AL2 uses yum and has no release lock, so the advisory installs directly:
# Which amazon-linux-extras topics are enabled
amazon-linux-extras
# Amazon's fix for the php8.2 extra
sudo yum update --advisory ALAS2PHP8.2-2026-015
sudo systemctl restart php-fpm httpd
The fixed build is 8.2.35-1.amzn2.0.1.
AWS's AL2023 guide notes that AL2's PHP 7.1 to 7.4 extras are end
of life with no guaranteed security updates, and AL2 itself is past
end of support, so plan the move to AL2023 rather than relying on
further AL2 fixes.
Containers
Images built on Amazon Linux
The 2023 and
latest tags on
public.ecr.aws/amazonlinux/amazonlinux
pointed at release 2023.12.20261026.1 on 27 October 2026, and each
release also has its own tag, such as 2023.12.20261021.0. A
Dockerfile pinned to an older tag still installs the vulnerable
PHP, because dnf inside the build uses that image's release.
FROM public.ecr.aws/amazonlinux/amazonlinux:2023
RUN dnf -y --releasever=latest upgrade \
&& dnf install -y php8.4-fpm php8.4-cli \
&& dnf clean all Rebuild, push and replace the running containers; updating packages inside a live container is lost on the next deploy. Check what a running container holds with:
docker exec CONTAINER rpm -q php8.4-fpm The general rebuild routine is in updating PHP in Docker.
Other places Amazon Linux PHP turns up
- Minimal images. The
2023-minimaltag uses microdnf, a smaller package manager without every dnf feature. Container images also lackdnf check-release-updateuntil you install it. - Lambda. The provided.al2023 runtime is built on the minimal image. AWS's bulletin says Lambda has no managed PHP runtime, so anyone running PHP as a custom runtime or container image must update it and redeploy the functions.
- Elastic Beanstalk. The bulletin says updated PHP platform versions for 8.2 to 8.5 are out. Environments with managed platform updates get them in the next maintenance window; others need their platform version updated.
- Amazon Linux 2027 Preview. Its php8.5 was fixed on 21 October 2026 in ALAS2027-2026-243.
Confirm it worked
Proof that an Amazon Linux server is patched
- 1. The PHP packages carry the fixed build.
rpm -qa 'php8*'shows the version from the advisory table, or a later one, on every line. - 2. The lock moved forward.
rpm -q system-releasereports 2023.12.20261021 or later, unless you deliberately used the advisory-only command and have a date to move the system. - 3. No PHP process predates the update. php-fpm, and Apache where mod_php is loaded, show a start time after the packages changed.
- 4. The live site agrees. A load balancer can send traffic to instances or containers you have not patched yet, so check the PHP version the site reports through its public address as well.
Since 26 October 2026 both CVEs have been on CISA's list of vulnerabilities exploited in the wild. An instance that served PHP to the internet before its update deserves a look for unexpected files and processes: has your PHP site been compromised?
Troubleshooting
When Amazon Linux will not take the fixed PHP
"Nothing to do" from dnf
The machine is locked to a release from before 21 October 2026.
Repeat the command with --releasever=latest
or the release number from step 2.
"No such command: check-release-update"
Container images leave the plugin out. Install it with
dnf install 'dnf-command(check-release-update)',
or skip it and pass --releasever=latest
directly.
A conflict when installing another PHP branch
Each php8.x family refuses to share a machine with another branch. Remove the old branch first, as in leaving php8.1, rather than forcing the install.
Dependency errors after the advisory-only update
This is the mixed-release problem AWS warns about. Move the whole
system with sudo dnf upgrade --releasever=latest
and the dependencies line up again.
The site still reports the old PHP, or php-fpm will not start
Look for a second PHP service, read the php-fpm journal, and check whether Apache has a PHP module loaded.
systemctl list-units 'php*'
journalctl -u php-fpm -e
httpd -M | grep -i php Amazon Linux shares dnf with Red Hat's family, whose stream-based packaging is covered in updating PHP on RHEL, AlmaLinux and Rocky. For apt-based servers see Ubuntu and Debian; the Linux overview and the main update guide cover the rest.
Quick answers
Amazon Linux PHP questions
Why does dnf update say there is nothing to do on Amazon Linux 2023?
Because dnf only looks at the repository version the machine is locked to, and Amazon puts new fixes only into new releases. A server launched from an AMI older than release 2023.12.20261021 sees no PHP update until you name a later release with --releasever, for example sudo dnf upgrade --releasever=latest.
Is php8.1 on Amazon Linux 2023 fixed?
No. The Amazon Linux Security Center lists php8.1 as No Fix Planned for both CVEs, and Amazon's package support statement ended php8.1 support on 31 December 2025. Move to php8.2 or later; php8.2 itself reaches end of support on 31 December 2026, so php8.3 or php8.4 buys more time.
Is Amazon Linux 2 still getting PHP fixes?
Only in part. AWS's FAQ says AL2 is past end of support and no longer receives standard security updates, yet Amazon issued ALAS2PHP8.2-2026-015 for the php8.2 extra on 22 October 2026. The core php package has no fix planned, and the older PHP extras are not listed. AWS's own advice is to migrate to AL2023.
Why does Amazon rate PHP2Shell Important when PHP calls it Critical?
Different scorers. Amazon gives both CVEs a CVSS 3.1 score of 8.1 and an Important rating, the National Vulnerability Database scores them 9.8, and the PHP project rates them Critical at CVSS v4.0 9.2. The fix and its urgency are the same whichever number you quote.
Can two PHP versions run side by side on Amazon Linux 2023?
Not from Amazon's packages. Each php8.x family declares a conflict with every other PHP branch, and all of them install the same php-fpm service and configuration paths. To serve sites on different branches, give each branch its own instance or container.
Know your exposure
Find every PHP server you run
Patching the server you know about is the easy part. A vulnerability scan finds the forgotten staging site, the old microsite and the appliance with PHP inside, then tells you which ones are still exposed.