7

Adding this code:

AddType application/x-httpd-php .php after

# AddEncoding x-compress .Z
# AddEncoding x-gzip .gz .tgz
#
# If the AddEncoding directives above are commented-out, then you
# probably should define those extensions to indicate media types:
#
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz

to C:\Apache24\bin\httpd.conf downloads all PHP pages on my system rather than render it.

Before then, the PHP pages were parsed as raw text.

Help needed!

Lucas
  • 523
  • 2
  • 10
  • 20
Lapys
  • 936
  • 2
  • 11
  • 27

2 Answers2

9

There are two problems:

  1. application/x-httpd-php is not a MIME type, but rather a handler. That means your directive must be AddHandler instead of AddType

  2. application/x-httpd-php is not a valid handler. The handler must include the PHP version digits at the end of the string

Putting that altogether, assuming, say PHP version 7.2, what you want is

   ✅ AddHandler application/x-httpd-php72 .php instead of
    AddType application/x-httpd-php .php

Lucas
  • 523
  • 2
  • 10
  • 20
  • 2
    This really ought to be the accepted answer... this fixed up some old pages right up for me after the hosting company auto-upgraded the site to PHP 7. Thanks, Lucas. – RwwL Dec 11 '19 at 20:18
  • for me it worked like this: (without version) ```AddHandler application/x-httpd-php .php``` – user3891775 Feb 28 '22 at 04:18
  • wrt. 1) It doesn't matter at all, whether it is a mime type or not! Everything what matters is, whether the module accepts this string, when it gets asked to process the request. If it gets passed an unknown name, it simply ignores the request. Wrt. 2) This is wrong wrt. to default code. The unmodified, i.e. original code accepts `application/x-httpd-php`, `application/x-httpd-php-source`, and `php-script`, only (see https://github.com/php/php-src/blob/master/sapi/apache2handler/sapi_apache2.c#L60). – jelmd Feb 26 '23 at 10:37
-2
add this at the bottom of your httpd.conf make sure you have php{version}apache{version}.dll in line 3 and directory of  your php.

AddHandler application/x-httpd-php .php
AddType application/x-httpd-php .php .html
LoadModule php7_module "c:/php7/php7apache2_4.dll"
PHPIniDir "c:/php7"

you can visit this link

rm_beginners
  • 164
  • 5