【问题标题】:AddType application/x-httpd-php .php is not rendering PHPAddType application/x-httpd-php .php 未呈现 PHP
【发布时间】:2017-08-19 15:44:09
【问题描述】:

添加此代码:

AddType application/x-httpd-php .php 之后

...
#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

C:\Apache24\bin\httpd.conf 下载我系统上的所有 PHP 页面而不是渲染它。

在此之前,PHP 页面被解析为原始文本。

需要帮助!

【问题讨论】:

  • 你是用 PHP 作为 fcgi 还是 apache 模块
  • PHP 作为 Apache 模块
  • 确保代码在 标签之间
  • 你是否将LoadModule 行添加到httpd.conf 中,这样PHP 才能真正加载到apache 中
  • @RiggsFolly 谢谢,这就是问题所在。

标签: php apache


【解决方案1】:

有两个问题:

  1. application/x-httpd-php 不是 MIME 类型,而是一个处理程序。这意味着您的指令必须是 AddHandler 而不是 AddType

  2. application/x-httpd-php 不是有效的处理程序。处理程序必须在字符串末尾包含 PHP 版本数字

总而言之,假设 PHP 版本 7.2,您想要的是

   ✅ AddHandler application/x-httpd-php72 .php 而不是
?AddType application/x-httpd-php .php

【讨论】:

  • 这真的应该是公认的答案...在托管公司将网站自动升级到 PHP 7 后,这为我修复了一些旧页面。谢谢,卢卡斯。
  • 对我来说它是这样工作的:(无版本)AddHandler application/x-httpd-php .php
【解决方案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"

你可以访问这个link

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-03-06
    • 2011-11-18
    • 1970-01-01
    • 2012-03-26
    • 2014-11-10
    • 1970-01-01
    • 1970-01-01
    • 2012-10-08
    相关资源
    最近更新 更多