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: