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.
<?php
phpinfo();
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.