php, aws, amazon linux 2,

Install PHP 8.1 on Amazon Linux 2

May 27, 2022 · 1 min read · Post a comment

If you want to hang out with the latest major update of PHP, then you should definitely try to install PHP 8.1 on Amazon Linux 2. Let’s do it.

Prerequisites

  • Amazon Linux 2
  • sudo privileges

Install PHP 8.1 on Amazon Linux 2

Step 1. Make sure system packages up to date.

sudo yum update

Step 2. Add the Remi repo as a stable yum repo, mainly used for the PHP stacks.

sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo yum install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
sudo yum install yum-utils

Step 3. Enable PHP 8.1 version.

sudo yum-config-manager --disable 'remi-php*'
sudo yum-config-manager --enable remi-php81

Step 4. Install PHP 8.1.

sudo yum install php81

Step 5. Verify installation.

php81 -v

Output:

PHP 8.1.6 (cli) (built: May 11 2022 01:14:18) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.1.6, Copyright (c) Zend Technologies

Conclusion

Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.