How to upgrade to PHP8.0 on Amazon Linux 2 EC2 instance?


Hi, I have upgraded the software I am hositng on EC2 instance but to funciton it requires PHP 8.0. I was not able to upgrade the PHP using the yup update and other Amazon tools I found on the forums. PHP version is stuck at 7.x and I really need to update to 8.0 on an urgent basis. Can you pleaes help?

asked 10 months ago6746 views
3 Answers

Have you tried

take a snapshot of your instance, Take a copy of php.ini, List the modules that you installed with php, yum remove -y php and its modules (php -m will give the modules list), amazon-linux-extras disable php7version, amazon-linux-extras enable php8version, yum install php and its modules.

answered 10 months ago

Have you tried changing the version of PHP using the following command

sudo update-alternatives --config php
profile picture
answered 10 months ago

You can install PHP 8.0, 8.1, 8.2 from amazon-linux-extras

amazon-linux-extras | grep php

May need to remove existing php7 packages first, before you enable 8.x package

sudo yum remove php*
sudo yum clean all
sudo amazon-linux-extras enable php8.0
sudo yum clean metadata
sudo yum install -q -y php-cli php-fpm php-opcache php-common
answered 10 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions