Apache 正在下载 php 文件而不是显示它们 [英] Apache is downloading php files instead of displaying them

查看:35
本文介绍了Apache 正在下载 php 文件而不是显示它们的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

操作系统和服务器信息:

OS and server information:

  • CentOS 6.4(最终版)
  • Apache 2.2.15
  • PHP 5.5.1

我之前安装了 php 5.3.x,但决定升级.我首先卸载了 php 5.3.x,然后安装了 php 5.5.1,但是在安装完成后,apache 没有解析它刚刚下载的 php 文件.我已经在 stackoverflow 中检查过类似的问题,但到目前为止没有一个对我有帮助.

I previously had php 5.3.x installed but decided to upgrade. I first uninstalled the php 5.3.x and then installed php 5.5.1 but after the installation completed apache did not parse the php files it just downloaded them. I have checked similar questions here in stackoverflow but none of them have helped me so far.

为了记录,我在 httpd.conf 和 php.conf 中有以下几行应该使 php 工作但不工作:

For the record I have the following lines in my httpd.conf and php.conf that should make php work but don't:

AddHandler application/x-httpd-php .php5 .php4 .php .php3 .php2 .phtml
AddType application/x-httpd-php .php5 .php4 .php .php3 .php2 .phtml
AddType application/x-httpd-php-source .phps
AddHandler php5-script .php

我真的很感激任何帮助.谢谢.

I would really appreciate any help. Thank you.

我在 php.conf 中有这些行

I have these lines in the php.conf

<IfModule !worker.c>
  LoadModule php5_module modules/libphp5.so
</IfModule>
<IfModule worker.c>
  LoadModule php5_module modules/libphp5-zts.so
</IfModule>

通过删除

AddType application/x-httpd-php .php5 .php4 .php .php3 .php2 .phtml

apache 不再下载文件.现在 apache 正在显示源代码,但并非全部只是一部分.我加了

apache no longer downloads the file. Now apache is showing the source code, but not all of it just part. I added

AddType text/html .php

但没有运气.

推荐答案

php 正确的 AddType 是 application/x-httpd-php

The correct AddType for php is application/x-httpd-php

AddType  application/x-httpd-php         .php
AddType  application/x-httpd-php-source  .phps

还要确保您的 php 模块已加载

Also make sure your php module is loaded

LoadModule php5_module        modules/mod_php55.so

当您配置 apache 时,然后尝试从另一个浏览器查看该页面 - 我曾有几天 chrome 顽固地缓存结果并不断下载源代码,而在另一个浏览器中却没问题.

When you're configuring apache then try to view the page from another browser - I've had days when chrome stubbornly caches the result and it keeps downloading the source code while in another browser it's just fine.

这篇关于Apache 正在下载 php 文件而不是显示它们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆