我在Debian上运行服务器,使用php-5
我的php文件名为pwrite.php,拥有755项权利,位于:
/ usr / lib中/的cgi-bin
<?php
$myfile = fopen("newfile.txt", "w") or die("Unable to open file!");
$txt = "John Doe\n";
fwrite($myfile, $txt);
$txt = "Jane Doe\n";
fwrite($myfile, $txt);
fclose($myfile);
?>
我希望它在cgi-bin文件夹中写'newfile.txt'
在
处使用apache2的错误日志 tail -f /var/log/apache2/error.log
我看到2个错误;
[[cgid:error] [pid 1328:tid 1996410880] (8)Exec format error: AH01241: exec of '/usr/lib/cgi-bin/phptest.php' failed
[[cgid:error] [pid 1268:tid 1963979824] [client ::1:35573] End of script output before headers: phptest.php
这两个错误只发生在我尝试使用CGI在我的服务器上执行代码时。
我在CGI文件夹中有一个工作的bash.sh脚本,用于显示系统信息。
没有找到关于500个错误的大量信息,除了它们很糟糕。我确实看到了这个链接,并想知道在这里使用cgi-bin是否存在问题?
我最终希望我的PHP解析所请求的URL(site.com/ar1/arg2)并将其解析为两个变量以便动态编写页面(/var/www/html/ar1/arg2/result.json)
我确定我的php文件具有正确的权限,而且我很确定我在默认的cgi-bin文件夹中启用.PHP文件,无需额外解析即可运行。