1

i'm new in AWS and Ubuntu i've facing a issue to execute php file on aws, i've already install php and apache.

enter image description here

when I access aws it show file is there,but this file in directory

var/www/html/phpinfo.php 

enter image description here

But when I delete file from var/www/html/phpinfo.php and past var/www/phpinfo.php no file show aws public IP, but on var/www/html/phpinfo.php it show plain php code

enter image description here

Update

follow these step in apache2,conf SetHandler application/x-httpd-php

then using terminal

sudo a2dismod mpm_event && sudo a2enmod mpm_prefork && sudo a2enmod php7

it show following message

considering conflict php5 for php7
module php7.0 already enabled

Enable Modes

etc/apache2/mods-enabled ls

I find these also

php7.0.conf and php7.0.load
Cœur
  • 37,241
  • 25
  • 195
  • 267
Zu007
  • 81
  • 1
  • 2
  • 8

2 Answers2

0

By default apache2 point to /var/www/html/ So if you put your file in /var/www/ it's normal that you don't seen the file.

To change this you can edit your apache2.conf file

vi /etc/apache2/apache2.conf

For your second issue (apache2 showing plain php code) It means that apache2 don't pass the code to your php interpreter.

Make sure that php is enable by checking that these 2 links are in the mod-enable folder in your /etc/apache2

lrwxrwxrwx 1 root root   29 août   3 14:30 php7.0.conf -> ../mods-available/php7.0.conf
lrwxrwxrwx 1 root root   29 août   3 14:30 php7.0.load -> ../mods-available/php7.0.load

if you don't have these links, type the following and try again:

a2enmod php7.0
service apache2 restart

.

Angel115
  • 2,135
  • 1
  • 17
  • 20
  • a2enmod php7.0 service apache2 restart Done mods-available/ php7.0.conf php7.0.log But still show index of empty no file there... but var/www/phpinfo.php already there – Zu007 Oct 06 '17 at 18:57
  • module php7.0 already enabled message show – Zu007 Oct 06 '17 at 19:21
-1

Installing Apache and PHP is not enough, you also have to configure Apache properly to handle its mod_php when a file with the ".php" extension is requested.

You can find tons of articles about how to do that here and there on the Web :-) , but here is a good example:

Rougemine
  • 1
  • 1
  • 1