How To Setup PHP 8.1 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 then add this apt repository which holds 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

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, which is 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

Leave a Comment

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