How to Install PHP 8.1 on Amazon Linux 2023

How to Install PHP 8.1 on Amazon Linux 2023

How to Install PHP 8.1 on Amazon Linux 2023

Dear Reader, how are you today? In my last few posts, you learnt how to install GitAnsible, DockerJava, Python etc. on Amazon Linux 2023 or AL2023 EC2 Instance.

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 –

  • Enums
  • Read-only properties
  • First-class callable syntax
  • Fibers
  • 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

Prerequisite

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

  1. Connect to your Amazon Linux 2023 Instance
  2. Run System Update
  3. Search for Available PHP Packages
  4. Install PHP 8.1 on Amazon Linux 2023
  5. 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.

Connect to EC2 Instance Instance using Ec2 instance connect

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.

Connected to Ec2 Instance AL2023

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.

How to Install Python on Amazon Linux 2023 3

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
How to Install PHP 8.1 on Amazon Linux 2023 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.

How to Install PHP 8.1 on Amazon Linux 2023 2

Step 5: Verify PHP 8.1 Installation

As we just installed PHP 8.1, let’s verify it.

php -v
How to Install PHP 8.1 on Amazon Linux 2023 3

Congratulation !!!

You have successfully installed PHP 8.1 on your Amazon Linux 2023 or AL2023 EC2 Instance.

Conclusion

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-

Suggested Read:

Leave a Reply

Your email address will not be published. Required fields are marked *