简体   繁体   English

未在 Aws Ec2 实例上为 PHP 7.2 执行 PHP 代码

[英]PHP Code Is Not Executed For PHP 7.2 On Aws Ec2 Instance

I am trying to install php on aws ec2 instance.我正在尝试在 aws ec2 实例上安装 php。 Since php 7.2 is not available, I used following commands to enable few repos as suggested in this Link由于 php 7.2 不可用,我使用以下命令来启用此链接中建议的少量存储库

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

Then I enabled a remi repo to run using sudo yum-config-manager --enable remi-php72然后我启用了 remi repo 使用sudo yum-config-manager --enable remi-php72
Then I ran sudo yum install php72然后我运行sudo yum install php72
All of them worked perfectly.他们都完美地工作。 But,When I ran php -v It gives error saying no such folder.但是,当我运行php -v它给出错误,说没有这样的文件夹。 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).我什至尝试将 index.php 添加到 /var/www/html 并且它没有被执行。而不是加载默认的 apache 页面(它似乎没有安装 php)。
But, when I ran php72 -v但是,当我运行php72 -v
It shows the current php version as 7.2它显示当前的 php 版本为 7.2
However, Index.php is not being executed.但是,Index.php 没有被执行。 Here also, it shows the apache default page when I try to access the index.php .在这里,当我尝试访问 index.php 时,它也会显示 apache 默认页面。
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.添加此符号链接后, php -v将 php 版本设为 7.2,而不是在添加符号链接之前没有出现此类文件夹错误。 But, still index.php is not being executed.但是,仍然没有执行 index.php。 It shows the apache default page when I try to access the index.php .当我尝试访问 index.php 时,它会显示 apache 默认页面。
Can someone help me to solve this problem?有人可以帮我解决这个问题吗? . . Thank You谢谢你

After browsing the internet for almost 1 and half days.浏览互联网近1天半后。 I was able to fix the problem.我能够解决这个问题。 I think the problem is with the installation procedure of php, using repos in aws ec2 instance.我认为问题在于php的安装过程,在aws ec2实例中使用repos。 When I installed php using当我安装 php 时使用
sudo yum install php72
There was nothing called php found inside /bin folder.在 /bin 文件夹中找不到任何名为 php 的东西。 However, there was php72.但是,有php72。 That is the reason for php -v not working and php72 -v to work resulting the php version.这就是php -v不工作而php72 -v工作导致 php 版本的原因。
This is for the AWS EC2 Instance这适用于 AWS EC2 实例
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)首先,删除旧的 php 版本(此命令将删除前面名称为 php 的所有内容,您需要以 root 身份执行此操作)

    yum remove 'php*'百胜删除'php *'

  2. Then type amazon-linux-extras install php7.2然后输入amazon-linux-extras install php7.2

  3. Confirm the php version by running php -v I hope this will become a help to someone.通过运行php -v确认 php 版本我希望这会对某人有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM