0

I have set 3 virtual hosts on an AWS Linux AMI instance, HTML files are working file but the PHP files are outputting plain text. Before I set up the vhosts I tested the PHP files and they were running fine.

I followed these instructions to install the LAMP stack on my instance: AWS Install LAMP

I have put the vhosts in the /etc/httpd/conf/httpd.conf file, and they look something like this:

<VirtualHost *:80>
ServerName domain1.com
DocumentRoot /var/www/html/domain1
<Directory /var/www/html/domain1>
AllowOverride All
</Directory>
</VirtualHost>

<VirtualHost *:80>
ServerName domain2.com
DocumentRoot /var/www/html/domain2
<Directory /var/www/html/domain2>
AllowOverride All
</Directory>
</VirtualHost>

<VirtualHost *:80>
ServerName domain3.com
DocumentRoot /var/www/html/domain3
<Directory /var/www/html/domain3>
AllowOverride All
</Directory>
</VirtualHost>

I tried adding this to httpd.conf

AddType application/x-httpd-php .php

but this makes turns the plain text PHP files into downloadable PHP files

Have I been missing something obvious all along?

Max
  • 11
  • 1
  • 2
    restarted apache ? In apache, do you LoadModule php ? – YvesLeBorg Oct 23 '17 at 14:50
  • Yes, I have tried restarting apache – Max Oct 23 '17 at 14:55
  • I tried adding LoadModule php5_module modules/libphp5.so but it returns an error – Max Oct 23 '17 at 14:57
  • Possible duplicate of [Apache Virtual Host not parsing PHP](https://stackoverflow.com/questions/9305680/apache-virtual-host-not-parsing-php) – randomir Oct 23 '17 at 14:59
  • Are you going to have us guess at the error you got from `LoadModule`? – stdunbar Oct 23 '17 at 15:08
  • I just tried with LoadModule php7_module modules/libphp-7.0.so which seems to be loading, restarted apache and the php file is still not being parsed – Max Oct 23 '17 at 15:16
  • 1
    I just managed to get it working by adding the following to `httpd.conf`: `LoadModule php7_module modules/libphp-7.0.so AddType application/x-httpd-php .php AddHandler php7-script .php` – Max Oct 23 '17 at 15:23

0 Answers0