PHP不运行脚本,而是下载它们

我知道,这是一个非常典型的问题,但我用尽了想法。 是的,该模块已安装:

# aptitude search libapache2-mod-php5 i libapache2-mod-php5 - server-side, HTML-embedded scripting language (Apache 2 module) p libapache2-mod-php5filter - server-side, HTML-embedded scripting language (apache 2 filter module) 

并启用:

 # ls -l /etc/apache2/mods-enabled/php* lrwxrwxrwx 1 root root 27 2011-08-31 13:49 /etc/apache2/mods-enabled/php5.conf -> ../mods-available/php5.conf lrwxrwxrwx 1 root root 27 2011-08-31 13:49 /etc/apache2/mods-enabled/php5.load -> ../mods-available/php5.load # cat /etc/apache2/mods-enabled/php5.conf <IfModule mod_php5.c> AddType application/x-httpd-php .php .phtml .php3 .php5 AddType application/x-httpd-php-source .phps </IfModule> # cat /etc/apache2/mods-enabled/php5.load LoadModule php5_module /usr/lib/apache2/modules/libphp5.so 

Apache声称PHP是lodade:

 # apache2ctl -t -D DUMP_MODULES Loaded Modules: core_module (static) log_config_module (static) logio_module (static) mpm_prefork_module (static) http_module (static) so_module (static) alias_module (shared) auth_basic_module (shared) authn_file_module (shared) authz_default_module (shared) authz_groupfile_module (shared) authz_host_module (shared) authz_user_module (shared) autoindex_module (shared) cgi_module (shared) deflate_module (shared) dir_module (shared) env_module (shared) mime_module (shared) negotiation_module (shared) php5_module (shared) proxy_module (shared) proxy_html_module (shared) proxy_http_module (shared) rewrite_module (shared) setenvif_module (shared) status_module (shared) Syntax OK 

文档根目录中没有.htaccess,而404表示PHP:

Apache / 2.2.9(Debian)PHP / 5.2.6-1 + lenny13与Suhosin-Patch proxy_html / 3.0.0服务器在wiki.example.com端口80

日志显示没有错误。

任何想法还有什么要检查?

首先,确保你的apacheconfiguration正在加载它,例如:

 LoadModule php5_module modules/libphp5.so 

然后,确保Apache知道解释.php文件,例如

 AddType text/html .php AddType application/x-httpd-php .php 

编辑

您提到错误日志不包含错误。 什么是.php脚本请求的状态代码? (200,500等)

在您的php.ini文件中,检查log_errorsdisplay_errorserror_log 。 如果错误正在logging,它们将位于由error_log指定的位置。 我认为这是默认行为(日志logging,不显示到屏幕上)。

如果您的应用程序需要MySQL,请确保您安装了php5-mysql软件包。 相同的其他所需的模块。

您不能同时使用处理程序模块在同一位置使用PHP和Passenger(每个请求只能“处理”一次,在这种情况下,Passenger正在处理请求)。 如果由于某种原因必须从Rails应用程序中提供PHP,则需要创build特定的位置或目录,并在该位置禁用Passenger,如下所示:

 <Directory /var/www/php/goes/here> PassengerEnabled off </Directory> 

要么

 <Location /php/goes/here> PassengerEnabled off </Location> 

更多在这里的官方文档

它看起来像closuresPassengerEnabled不启用DirectoryIndex,所以你可能需要手动重写从^ / php /去/这里/ $到/php/goes/here/index.php

此外,它看起来像使用PassengerHighPerformance阻止你closures它。

或者,切换到使用libapache2-mod-php5filter并拨弄它,直到Apache获取它作为输出filter后乘客处理请求和输出php代码。

我不确定发生了什么问题,因为我正在修正这些问题,Chrome不断向我显示PHP文件的下载。 它仍然有,而其他浏览器显示正在执行的PHP。 Chrome是否使用了一些caching? 无论如何,因为我问了这个问题,唯一缺less的部分是安装php5-mysql。

我已经设法解决这个问题在我的一台服务器上。

原来这是由“坏”文件名匹配的地方。 我改名为默认的index.html“它的工作!” 文本到index.html.bak。 没问题吧? 事实certificate,Apache实际上服务该.bak文件,而不是index.php。