9951 explained code solutions for 126 technologies


php-awsHow can I use Yum to install PHP on an Amazon EC2 instance?


Yum is a package manager for Linux distributions that can be used to install PHP on an Amazon EC2 instance. The following steps can be used to install PHP on an Amazon EC2 instance using Yum:

  1. Update the Yum package manager:
sudo yum update
  1. Install the PHP packages:
sudo yum install php php-mysql
  1. Verify the installation by running the following command:
php -v

Output example

PHP 7.2.34 (cli) (built: Mar 24 2020 11:01:37) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
  1. Configure the PHP settings:
sudo vi /etc/php.ini
  1. Restart the Apache web server:
sudo service httpd restart
  1. Test the PHP installation by creating a PHP info page:
sudo vi /var/www/html/info.php
  1. Test the page by visiting the URL in a web browser:
http://<ec2-instance-ip>/info.php

Helpful links

Edit this code on GitHub