How to Install PHP 7.4 or 7.3 or 7.2 on AWS EC2 Instance

How to Install PHP 7.4 or 7.3 or 7.2 on AWS EC2 Instance

In this article, I’m going to tell you how to install PHP 7.4 or 7.3 or 7.2 on aws EC2 instance. To do that you need to first set up an EC2 instance. Once you have done with EC2 instance creation, you need connect your EC2 instance console using SSH or EC2 Management console.

Connect your EC2 instance

Install PHP on AWS EC2 Instance

you need to update your privileges to root user (sudo su) before installing the PHP.

Install PHP on AWS EC2 Instance

let’s install PHP into the EC2 instance

Install the Apache web server.

Check the server running status

If you found server is inactive then start the web server with the command shown following.

Now copy your EC2 Instance Public DNS something like: ec2-54-xxx-xxx-xxx.compute-1.amazonaws.com and paste it on your browser to check apache server is running or not.

Install PHP 7.4 on server

Confirm that the amazon-linux-extras package is installed:

If the command doesn’t return any output, then install the package that will configure the repository:

Install PHP 7.4, 7.3, 7.2 on Amazon AWS EC2

Let’s confirm that PHP 7.x topic is available in our AWS EC2 machine:

As we can see all PHP 7 topics, in this example we’ll enable php7.4 topic.

Now install PHP packages from the repository.

Accept installation of PHP 7 packages on AWS EC2.

Check default PHP version

To install PHP 7.2, make sure you disable 7.4 and 7.3 then enable 7.2.

Confirm version of PHP

Similar commands should be used when installing PHP 7.3 on Amazon AWS EC2.

Also Read: How to Import MySQL Database from SQL File using PHP

Conclusion:

Now we have installed PHP into our EC2 instance. Hope I was able to help someone out. If you have any questions feel free to ask anything on the comment section. Cheers!!.

Are you want to get implementation help, or modify or extend the functionality of this script? Submit a paid service request

Related posts