How to Install PHP 8.1 on Amazon Linux 2023
In this quick blog post, we’ll discuss how to install PHP 8.1 on Amazon Linux 2023 EC2 instance in a step-by-step manner.
So are you ready?
Alright, let’s get started.
Don’t want to miss any posts from us? join us on our Facebook group, and follow us on Facebook, Twitter, LinkedIn, and Instagram. You can also subscribe to our newsletter below to not miss any updates from us.
A bit on PHP 8.1 and Amazon Linux 2023(AL2023)
PHP 8.1: PHP 8.1 is a major update to the ohh so popular PHP language. It has several new features such as –
- Read-only properties
- First-class callable syntax
- Intersection types
- performance improvements etc.
Amazon Linux 2023: Amazon Linux 2023 or AL2023 is the next-generation Amazon Linux AMI provided by AWS.
- It is rpm based and optimized for the cloud.
- It is designed with the latest Linux innovations to deliver high-performance and stable Linux systems.
- Based on Fedora
- Better security features
Before you install PHP 8.1 on your Amazon Linux 2023 or AL2023 EC2 instance, You need to have an EC2 instance up and running.
Here is a tutorial to help launch an Amazon Linux 2023 easily-
Additionally, if you don’t have a free tier account, check out how to setup a free tier AWS account in right way. Having said that, don’t forget to set up a cost budget to avoid last-minute billing shocks.
Steps to Install PHP 8.1 on Amazon Linux 2023 Instance
- Connect to your Amazon Linux 2023 Instance
- Run System Update
- Search for Available PHP Packages
- Install PHP 8.1 on Amazon Linux 2023
- Verify PHP Installation
Step 1: Connect to your Amazon Linux 2023 Instance
By this time, I assume you already have an Amazon Linux 2023 instance up and running. Therefore you are all set to install PHP 8.1 on it. However, If that’s not the case, feel free to launch one using one of my previous tutorials.
Once your Amazon Linux 2023 EC2 instance is up and running, select your instance and click on Connect as shown in the below screenshot.
Verify that ec2-user is showing in the user name field and click Connect again.
In a matter of seconds, you should be connected to your instance as shown below.
Important Note: If you prefer connecting from your local, feel free to use the command- ssh -i /path/my-key-pair.pem ec2-user@instance-public-ip
Step 2: Run System Update
Before we install any software in your Amazon Linux 2023 instance, it’s recommended to update your system packages to the latest.
You can run the system update using the below command-
sudo dnf update
Type sudo dnf update and hit enter.
Step 3: Search for Available PHP Package on AL2023
You can search all PHP 8.1 and its related packages using-
sudo dnf search php8.1
As you can notice in the above screenshot, PHP 8.1 and related packages are available in Amazon Linux 2023 core repository. And the first among them(highlighted) is the one we are interested in.
Step 4: Install PHP 8.1 on Amazon Linux 2023
As you saw the package name above, the one line to install PHP 8.1 on your Amazon Linux 2023 or AL2023 would be –
sudo dnf install php8.1 -y
Type the above command and hit enter. In a matter of seconds, PHP 8.1 and all its dependencies will be installed on your Amazon Linux 2023 as shown below.
Step 5: Verify PHP 8.1 Installation
As we just installed PHP 8.1, let’s verify it.
You have successfully installed PHP 8.1 on your Amazon Linux 2023 or AL2023 EC2 Instance.
In this how-to guide, we talked about How to Install PHP 8.1 on Amazon Linux 2023 EC2 Instance
We started with checking the available PHP packages on Amazon Linux 2023. Then we installed PHP 8.1 on our instance. Lastly, we verified the PHP 8.1 installation.
Were you able to install PHP 8.1 on AL2023 using this tutorial? Let me know in the comment section.
Enjoyed the content?
Subscribe to our newsletter below to get awesome AWS learning materials delivered straight to your inbox.
Don’t forget to motivate us-