Skip to content
Advertisement

PHP Code Is Not Executed For PHP 7.2 On Aws Ec2 Instance

I am trying to install php on aws ec2 instance. Since php 7.2 is not available, I used following commands to enable few repos as suggested in this Link

  1. sudo yum install epel-release
  2. sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
  3. sudo yum install yum-utils

Then I enabled a remi repo to run using sudo yum-config-manager --enable remi-php72
Then I ran sudo yum install php72
All of them worked perfectly. But,When I ran php -v It gives error saying no such folder. I even tried adding an index.php to /var/www/html and it does not get executed.Instead of that default apache page is loaded(Its seems that php is not installed).
But, when I ran php72 -v
It shows the current php version as 7.2
However, Index.php is not being executed. Here also, it shows the apache default page when I try to access the index.php .
I even tried adding a symbolic link as follows

ln -s /usr/bin/php72 /usr/bin/php

After adding this symbolic link, php -v gives the php version as 7.2 instead of no such folder error which came prior to adding symbolic link. But, still index.php is not being executed. It shows the apache default page when I try to access the index.php .
Can someone help me to solve this problem? . Thank You

Advertisement

Answer

After browsing the internet for almost 1 and half days. I was able to fix the problem. I think the problem is with the installation procedure of php, using repos in aws ec2 instance. When I installed php using
sudo yum install php72
There was nothing called php found inside /bin folder. However, there was php72. That is the reason for php -v not working and php72 -v to work resulting the php version.
This is for the AWS EC2 Instance
These are the steps I followed to fix the issue.

  1. First, remove old php versions(This command will remove every thing with the name php in front and you need to be root to perform this)

    yum remove ‘php*’

  2. Then type amazon-linux-extras install php7.2

  3. Confirm the php version by running php -v I hope this will become a help to someone.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement