PHP - FastCGI - Http Error 500.0 - Internal server error

2.5k views Asked by At

I'm currently working with an IIS server and trying to access an index.php file.

To make IIS recognize php files, as it doesn't do it by default, if you try to access a *.php link you normally would get Error 404; so to solve this I found this solution and applied it:

GLOBAL FASTCGI HANDLER MAPPING FOR PHP

The php-cgi.exe file required for the solution was downloaded as a zip from this page as a VC14 x64 Thread Safe :

windows. php . net/download (separated the link because it wouldn't allow me to put more than 2 links)

The code of the php file is this one, it's a simple one but I don't know if it could be the cause of the 500.0 error, I tried things like removing the quotes from the $psDIR but it didn't work so I put them back.
Also used the ini_set('display_errors', 1); line to check the errors or malfunctions but it never showed anything (I hoped it showed something in the web browser, don't know if there's where I should expect the error display to appear but I expected it there). So here's my code:

<?php
$psPath = "powershell.exe";
$psDIR = "C:\\Users\\ovman\\workspace\\TestingPowerShellPlugIn\\src\\";
$psScript = "Test1.ps1";
$runScript = $psDIR. $psScript;
$runCMD = $psPath." ".$runScript." 2>&1";

echo "\$psPath  $psPath <br>";
echo "\$psDIR  $psDIR <br>";
echo "\$psScript  $psScript <br>";
echo "\$runScript  $runScript <br>";
echo "\$runCMD   $runCMD  <br>";

exec( $runCMD,$out,$ret);

echo "<pre>";
print_r($out);
print_r($ret);
echo "</pre>";

ini_set('display_errors', 1);
?>

When I tried accessing it from a remote computer it just says internal error 500.

And when I access it through the localhost server, I get this response:

Http Error 500.0 - internal server error

I also started checking the IIS logs and this is what is written in the last one (I tried to access the page several times so it looks like this, and I'm new to this so I really don't get what it says in there but hope it's useful):

Software: Microsoft Internet Information Services 8.5
Version: 1.0
Date: 2017-01-03 17:38:00
Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) cs(Referer) sc-status sc-substatus sc-win32-status time-taken
2017-01-03 17:38:00 192.168.1.73 GET /index.php - 443 - 192.168.1.125 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/55.0.2883.87+Safari/537.36 - 500 0 267 156
2017-01-03 17:41:07 ::1 GET /index.php - 80 - ::1 Mozilla/5.0+(Windows+NT+6.3;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/55.0.2883.87+Safari/537.36 - 500 0 267 4
2017-01-03 17:41:29 ::1 GET /index.php - 80 - ::1 Mozilla/5.0+(Windows+NT+6.3;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/55.0.2883.87+Safari/537.36 - 500 0 267 13
2017-01-03 17:41:29 ::1 GET /index.php - 80 - ::1 Mozilla/5.0+(Windows+NT+6.3;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/55.0.2883.87+Safari/537.36 - 500 0 267 12
2017-01-03 17:41:30 ::1 GET /index.php - 80 - ::1 Mozilla/5.0+(Windows+NT+6.3;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/55.0.2883.87+Safari/537.36 - 500 0 267 5
2017-01-03 17:41:31 ::1 GET /index.php - 80 - ::1 Mozilla/5.0+(Windows+NT+6.3;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/55.0.2883.87+Safari/537.36 - 500 0 267 4
2017-01-03 17:41:31 ::1 GET /index.php - 80 - ::1 Mozilla/5.0+(Windows+NT+6.3;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/55.0.2883.87+Safari/537.36 - 500 0 267 2
2017-01-03 17:41:31 ::1 GET /index.php - 80 - ::1 Mozilla/5.0+(Windows+NT+6.3;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/55.0.2883.87+Safari/537.36 - 500 0 267 7
2017-01-03 17:41:31 ::1 GET /index.php - 80 - ::1 Mozilla/5.0+(Windows+NT+6.3;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/55.0.2883.87+Safari/537.36 - 500 0 267 3
2017-01-03 17:41:32 ::1 GET /index.php - 80 - ::1 Mozilla/5.0+(Windows+NT+6.3;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/55.0.2883.87+Safari/537.36 - 500 0 267 2
2017-01-03 17:41:32 ::1 GET /index.php - 80 - ::1 Mozilla/5.0+(Windows+NT+6.3;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/55.0.2883.87+Safari/537.36 - 500 0 267 3
2017-01-03 17:41:32 ::1 GET /index.php - 80 - ::1 Mozilla/5.0+(Windows+NT+6.3;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/55.0.2883.87+Safari/537.36 - 500 0 2147500037 4
2017-01-03 17:41:32 ::1 GET /index.php - 80 - ::1 Mozilla/5.0+(Windows+NT+6.3;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/55.0.2883.87+Safari/537.36 - 500 0 2147500037 2
2017-01-03 17:41:32 ::1 GET /index.php - 80 - ::1 Mozilla/5.0+(Windows+NT+6.3;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/55.0.2883.87+Safari/537.36 - 500 0 2147500037 16
2017-01-03 17:41:32 ::1 GET /index.php - 80 - ::1 Mozilla/5.0+(Windows+NT+6.3;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/55.0.2883.87+Safari/537.36 - 500 0 2147500037 2
2017-01-03 17:41:33 ::1 GET /index.php - 80 - ::1 Mozilla/5.0+(Windows+NT+6.3;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/55.0.2883.87+Safari/537.36 - 500 0 2147500037 8
2017-01-03 17:41:34 ::1 GET /index.php - 80 - ::1 Mozilla/5.0+(Windows+NT+6.3;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/55.0.2883.87+Safari/537.36 - 500 0 2147500037 14

EDIT:

I know it isn't the Powershell permissions as I ran the (.ps1) powershell file directly and it ran without trouble. I had the execution policies set as Unrestricted, and also did a java program to check if I could run the file (it is similar to my index.php code) and it executed the file with no problems.

New EDIT:

So apparently error log doesn't work too well, as FastCGI does not return the error to debug, which is why I created a new folder with permissions for anyone to edit, set the new log file in which php could display the errors, added

log_errors = On
error_reporting = E_ALL
error_reporting(E_ALL)

That last line in the index.php code, but didn't get the logs. I know they are supposed to be somewhere, I also used

error_log = syslog

and also used a variant

error_log = C:\...

but neither worked. Still checking other posts to know how could I find the log, to know what's been happening and correct the error.

0

There are 0 answers