I am running a server on Debian, using php-5
My php file is called pwrite.php, has 755 rights and is located at:
/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);
?>
I am expecting it to write 'newfile.txt' in cgi-bin folder
Using the error logs for apache2 at
tail -f /var/log/apache2/error.log
I see 2 errors;
[[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
Both of these errors only happen when I try and execute code on my server using CGI.
I have a working bash.sh script in the CGI folder that displays system information.
Didn't find a lot of info on 500 errors, except they suck. I did see this link and wonder if using cgi-bin is the issue here?
I ultimately want my PHP to resolve the URL requested (site.com/ar1/arg2) and parse this into two variables in order to write pages dynamically (/var/www/html/ar1/arg2/result.json)
I'm sure that my php file has the correct permissions, and I'm pretty sure I've enabled .PHP files in my default cgi-bin folder to run without additional parsing.