Installing PHP 7.2 Instead of PHP 5.4 on Amazon Linux 2
Problem
When you launch a new Amazon Linux 2 AMI server and try to install PHP using the following command:
After a successful installation, if you check the version using php -v
, you'll see:
However, the latest PHP version is 7.2, and you may want to use this newer version instead.
Solution
You can enable PHP 7.2 via Amazon Linux Extras with the following command:
Once it is enabled, follow the subsequent instructions to complete the installation:
That's it. Check the PHP version again using php -v
, and it should now display: