【发布时间】:2012-05-11 18:44:55
【问题描述】:
我正在与一位同事合作,在 XAMPP 中的 MAC 上设置他们的本地环境,在 Windows 上,我的虚拟主机如下所示。
当我访问像 http://domain.local/cgi-bin/handler.php 这样的 URL 时,Web 服务器会正确处理 PHP,但在他的服务器上我们会收到 500 服务器错误和此消息...
The server encountered an internal error and was unable to complete your request.
Error message:
Premature end of script headers:
我们尝试将 cgi-bin 文件夹的名称更改为其他名称,因为我注意到 httpd.conf 中有另一个别名,但这没有效果......所以在我看来问题与权限相关。
我们认为别名设置正常,因为访问不存在的 http://domain.local/cgi-bin/filenothere.php 会按预期抛出 404,任何 .html/.pl 文件都无法执行。
cgi-bin 文件夹上存在的权限是...
rwxrwxrwx 戴夫员工
并且归用户和组所有....
戴夫员工
虚拟主机
<VirtualHost *:80>
ServerAdmin webmaster@example.com
ServerName www.domain.local
ServerAlias domain.local
ServerAlias api.domain.local
# Indexes + Directory Root.
DirectoryIndex index.php
DocumentRoot E:/home/www/www.domain.co.uk/htdocs/
# CGI Directory
ScriptAlias /cgi-bin/ E:/home/www/www.domain.co.uk/cgi-bin/
<Location /cgi-bin>
Options +ExecCGI
</Location>
# Logfiles
ErrorLog E:/home/www/www.domain.co.uk/logs/error.log
CustomLog E:/home/www/www.domain.co.uk/logs/access.log combined
</VirtualHost>
知道是什么导致这个 PHP 文件无法执行吗?
更新 尝试在 PHP 文件的开头添加一个标头来说明内容是 PHP,现在这只是输出 PHP 代码。
就好像在别名中指定的任何路径都可以访问,但服务器不知道如何执行内容,这适用于 HTML 和 PHP
【问题讨论】:
-
你确定问题不在于 handler.php 吗?该文件的权限是什么?
-
为整个文件夹递归地设置了权限,以尝试使其正常工作。我用一些额外的信息更新了问题。
-
感谢大家的建议,今天会看看他们并尝试分配这个赏金
标签: php xampp virtualhost cgi-bin