php, aws, amazon linux 2,

How to install PHP 7.4 on Amazon Linux 2

Dec 24, 2021 · 1 min read · Post a comment

Setting up a PHP environment for a PHP-based project on Amazon Linux 2 it’s a straightforward process, and it can be achieved in a few steps. This tutorial is aimed to show you the steps for installing PHP 7.4 on Amazon Linux 2.

Prerequisites

  • Amazon Linux 2
  • sudo privileges

Install PHP 7.4 on Amazon Linux 2

Step 1. Install the amazon-linux-extras package.

sudo yum install amazon-linux-extras

Step 2. Make sure that the PHP 7.4 is available.

sudo  amazon-linux-extras | grep php

Output:

php7.3                   available    \
php7.4                   available    [ =stable ]
php8.0                   available    [ =stable ]

Step 3. Enable PHP 7.4 package.

sudo amazon-linux-extras enable php7.4

Step 4. Install PHP 7.4 on Amazon Linux 2.

sudo yum install php php-{pear,cgi,common,curl,mbstring,gd,mysqlnd,gettext,bcmath,json,xml,fpm,intl,zip,imap}

Step 5. Verify PHP version.

php --version

Output:

PHP 7.4.5 (cli)
Copyright (c) The PHP Group

Conclusion

If you need help on how to switch to another PHP version put a comment below. Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.