Select Language:
If you’re working with Amazon Linux 2023 (AL2023) and want to change your PHP version, you’re in luck because AL2023 supports several PHP versions like 8.1, 8.2, 8.3, and 8.4. However, PHP 8.5 isn’t officially supported in this environment, which might make it confusing if you’re seeing this version pop up.
Here’s a simple way to switch your PHP version to the one you prefer:
Start by checking which PHP versions are available to install. Open your terminal and run:
bash
dnf list available | grep php
This command will list all the PHP packages ready to install. Once you’ve identified the PHP version you want, such as 8.4, install it with:
bash
sudo dnf install php8.4
If your system already has multiple PHP versions installed, you’ll probably want to set the default version to avoid any confusion. Use this command:
bash
sudo alternatives –set php /usr/bin/php8.4
After making changes, verify your current PHP version to ensure everything went smoothly:
bash
php -v
If you’re deploying your application through AWS Elastic Beanstalk, you have another easy option. You can choose a platform branch specifically designed for PHP 8.4 on AL2023. This setup comes with PHP 8.4.4, Composer 2.8.5, and default web servers like nginx 1.26.3 or Apache 2.4.62, depending on your choice.
Keep in mind that moving between PHP versions might cause some compatibility issues with your existing code. It’s a good idea to review PHP’s migration documentation to make sure your code works smoothly with the new version.
For more detailed information, you can check out these official resources:





