How To Setup PHP 8.1 / 8.3 In AWS Using Ubuntu OS

You are currently viewing How To Setup PHP 8.1 / 8.3 In AWS Using Ubuntu OS

This Article shows how to Install PHP 8.1 on Ubuntu OS using AWS Cloud

First, update the apt using the following command.

sudo apt-get update

When your APT is updated, add this apt repository with PHP installing .deb packages.

sudo add-apt-repository ppa:ondrej/php

So now as we set the repository for php8.1, please run the below command to install PHP 8.1

sudo apt-get install php8.1 -y

If you want to install PHP 8.3 then run the command below ( optional )

sudo apt-get install php8.3 -y

Next, reboot the Apache server.

sudo apt-get install apache2 -y
sudo systemctl restart apache2

Set Apache to restart automatically when the system reboots.

sudo systemctl enable apache2

That’s it, you have successfully installed PHP 8 on your Ubuntu machine. To test the installation, run the following command.

php -v

Alternatively, you can create a PHP file in this path, “/var/www/html/info.php” and put the content as below.


That’s it. Restart the server and enjoy PHP 8.1 on your EC2 instance.

I have created a video for this tutorial hosted on YouTube. If you are stuck in the middle of the process then you can view the video for help.

Related Articles

Set Up SSL into Ubuntu

Atiqur Rahman

I am MD. Atiqur Rahman graduated from BUET and is an AWS-certified solutions architect. I have successfully achieved 6 certifications from AWS including Cloud Practitioner, Solutions Architect, SysOps Administrator, and Developer Associate. I have more than 8 years of working experience as a DevOps engineer designing complex SAAS applications.

Leave a Reply