How to Install PHP 8 on AWS EC2 instance

You are currently viewing How to Install PHP 8 on AWS EC2 instance

PHP8 officially launched on Nov 26, 2020. In this article, I will show you how you can install PHP8 on AWS EC2. To do this, first set up an EC2 instance using the following article of mine. While choosing the AMI type, select Ubuntu 20.

Next, 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 the php8, please run the below command to install PHP8

sudo apt-get install php8.0 -y

Next, reboot the apache server.

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 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:

Install MySQL on Ubuntu

Make money as an AWS Expert

SET UP SSL With PHP 8 and Apache in AWS

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