PHP Errors/warning on IIS 7.5

Hi

I have php installed on my IIS 7.5 as FastCGI. The problem is, that if there are any errors at all, it just shows me a blank white screen. I do not actually see the error message. Which makes debugging and finding the error a lot more difficult.

I have checkted my php.ini settings and all seems good. What could the problem be?

And while we on the subject, but a bit off-topic. Every error in .NET just gives a 500 error. And I must RDP and run the site locally on the server to get the actual error. Is there a way to turn that off? Might also be realated to PHP error above?

But it is only for .NET module errors, normal errors show correctly.

Thanks

Regarding the errors for PHP on IIS 7.5 have you checked the phperror log? The path to it is in php.ini. I can’t tell you why the screen is coming up blank. If there is an error thrown on the web server it should normally show what the error is. 500, 503, 404, etc.

To fix the error in ASP.NET go check your web.config file and look for how it is reporting errors there. Most likely you have it set to remoteonly which is useless for debugging. this article has some good info on how to set up for debugging purposes, http://msdn.microsoft.com/en-us/library/h0hfz6fc.aspx

btw, since you are dealing with a remote server here you should know about two modules that might be helpful.

Advanced Logging Module - http://www.iis.net/download/AdvancedLogging
Remote Admin Module - http://www.iis.net/download/IISManager

oh and make sure you are using WinCache for any PHP applications you are running on Windows/IIS. Essentially memcache for PHP on Windows, http://www.iis.net/download/WinCacheForPHP

hope that helps.

Hi Mark Brown I have a similar problem to that Posted by NightStalker-DNS
I am following the ‘PHP Object-Oriented Solutions’ exercises by David Powers and the problem is manifest from Ex1, I dont have a
blank screen as NightStalker-DNS has - I have a 500 error ‘The website cannot display the page’.
The exercise starts with ‘view’ & ‘class’ files being opened and coded as follows:


Class file - Product.php
<?php
class Ch2_Product
{
  // properties defined here
  protected $_type = 'Book';

  // methods defined here

}

View file - product_test.php
<?php
c
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.3.org/1999/xhtml">
<head>
<title>Experimenting with visability</title>
<meta http-equiv="content-type"
   content="text/html; charset=iso-8859-1" />
</head>
<body>
<?php
  // include the class file
  require_once '../Ch2/Product.php';

  // create an instance of the Ch2_product class
  $product = new Ch2_Product();

  // display the $_type property
  echo $product->_type;

?>
</body>
</html>

Because no methods are included in the class file this throws an error it should read ‘Fatal error cannot access protected property Ch2_Product:$_type in C:\htdocs…(address of view file) on line 5’
My problem is my browser shows the 500 error instead of the error message above.
With the addition of the method:


public function getProductType()
{
  return $this->_type
}

the value ‘Book’ is shown on screen.
I am using a recently purchased 64bit computer running a Windows Vista Business OS and IIS7.
The php.ini file has error_reporting = E_ALL & ~E_NOTICE, display_errors = “stderr”, display_errors = On activated and the following by default: display_startup_errors = Off, log_errors = Off. log_errors_max_len = 1024, ignore_repeated_source = Off, report_memleaks = On & rack_errors = Off
You will note that ‘set_ini(‘display_errors’, ‘1’);’ has been included in the view file for users with bhlank screens as NightStalker-DNS has.
Not sure what you mean by ‘have you checked the phperror log?’ I note an entry ‘;error_log = syslog’ which has not been enabled, but is this for my OS?
I have found an error log which reads as follows:
#Software: Microsoft Internet Information Services 7.0
#Version: 1.0
#Date: 2010-10-20 20:34:09
#Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) sc-status sc-substatus sc-win32-status time-taken
2010-10-20 20:34:09 ::1 GET /Ch2Visability/ch2_exercises/Product_test.php - 80 - ::1 Mozilla/4.0+(compatible;+MSIE+8.0;+Windows+NT+6.0;+WOW64;+Trident/4.0;+SLCC1;+.NET+CLR+2.0.50727;+.NET+CLR+3.5.30729;+.NET+CLR+3.0.30729;+.NET4.0C) 500 0 0 711

Any suggestions how to get errors reported without the 500 error woulb be greatly appreciated?

Please note a copy error in my php code:


<?php
set_ini('display_errors', '1');
?>
<!DOCTYPE

instead of ‘c’.
Thanks.

First I would go install the PHP Manager for IIS (http://phpmanager.codeplex.com/). Click on the web folder for the sub web in IIS for these examples and then run PHP Manager sitting on the right side. This is a handy little tool that will make sure that PHP is configured properly for your IIS site.

If you already have a path for the php log file click that link and see if there is anything in there that may indicate what the issue may be.

In this tool you can configure your error reporting. Under PHP Settings click the “Configure error reporting” and set the path to the php log file. also check the option for a development machine as well.

save your changes and rerun the example to see if you get a better description of the error.

hope that helps.
Mark

Hi Mark, I have installed PHP Manager for IIS on my computer and have accepted the recommendationd to optimally configure the IIS and PHP.
the following is the report found in the log file:
[25-Oct-2010 23:44:35] PHP Warning: PHP Startup: Unable to load dynamic library ‘C:\Program Files (x86)\PHP\ext\php_mssql.dll’ - The specified module could not be found. in Unknown on line 0

I have noted the reference to ‘php_mssql.dll’ and realise that I have activated 2 of the SQL extensions but not yet downloaded a copy of the Mysql database (this exercise not including a DB to link to) I have looked into the ini file and edited out the ‘;extension=php_mssql.dll ;extension=php_mysql.dll’ extensions (note these extensions are immediately following the file which is listed in the log file).
I also note that the Default Document has changed from index.php to Default.htm (which is not strictly part of this website and not saved in the root file, I am using a file with this name to launch this website but it resides in a different directory remote from the root directory)? How did the manager find this I wonder?
I have rerun the website (which again shows a 500 error) then checked the log file again and now have a second report as follows:
[25-Oct-2010 23:52:53] PHP Warning: PHP Startup: Unable to load dynamic library ‘C:\Program Files (x86)\PHP\ext\php_mssql.dll’ - The specified module could not be found. in Unknown on line 0

The .dll file exists in the directory ‘C:\Program Files (x86)\PHP\ext\’ but why is PHP IIS trying to run or load this file?
What can be preventing this file from loading if it really is required, and how can I get it to load?
Thanking you in anticipation for your reply.

Hi Mark, I have spent much time lately adding to items populating my website and reviewed the oop exercise I had been working on, on my newer 64bit computer on running same it produced a different 500 error page which has made me think there is a problem with security and ability to view drivers.
the page is learn.iis.net > 266 > trouble shooting
I am away from my computer to have a bit back soon.
Edward

try opening php.ini and do a CTRL-F for mssql in there. I think you are missing other references further down in the file that refer to the mssql extension. Just commenting that out once is probably now what’s causing that error because the references elsewhere expect it to be there.

that should fix this error you are seeing.

btw, make sure you are running 32 bit extensions. Even though you are running on a 64 bit machine you need to make sure everything is 32 bit. (there actually isn’t a 64 bit build for PHP-Windows).

hope that helps.
mark

Hi Mark The following are the extensions coppied from php.ini
;extension=php_bz2.dll
;extension=php_curl.dll
;extension=php_dba.dll
;extension=php_dbase.dll
;extension=php_exif.dll
;extension=php_fdf.dll
;extension=php_gd2.dll
;extension=php_gettext.dll
;extension=php_gmp.dll
;extension=php_ifx.dll
;extension=php_imap.dll
;extension=php_interbase.dll
;extension=php_ldap.dll
;extension=php_mbstring.dll
;extension=php_mcrypt.dll
;extension=php_mhash.dll
;extension=php_mime_magic.dll
;extension=php_ming.dll
;extension=php_msql.dll
;extension=php_mssql.dll
;extension=php_mysql.dll
;extension=php_mysqli.dll
;extension=php_oci8.dll
;extension=php_openssl.dll
;extension=php_pdo.dll
;extension=php_pdo_firebird.dll
;extension=php_pdo_mssql.dll
;extension=php_pdo_mysql.dll
;extension=php_pdo_oci.dll
;extension=php_pdo_oci8.dll
;extension=php_pdo_odbc.dll
;extension=php_pdo_pgsql.dll
;extension=php_pdo_sqlite.dll
;extension=php_pgsql.dll
;extension=php_pspell.dll
;extension=php_shmop.dll
;extension=php_snmp.dll
;extension=php_soap.dll
;extension=php_sockets.dll
;extension=php_sqlite.dll
;extension=php_sybase_ct.dll
;extension=php_tidy.dll
;extension=php_xmlrpc.dll
;extension=php_xsl.dll
;extension=php_zip.dll
All are non active with the semicolon in front. Is this what you expect?
Edward

Mark, In a 64bit machine I have a directory 'Program files (x86) which doesn’t exist in my 32bit computer, there is a complete set of php files in this directory including a PHP file which is much the same as the php.ini file but some what rearranged.
Is this the ini file being used and not the one in the windows directory?


btw, make sure you are running 32 bit extensions. Even though you are running on a 64 bit machine you need to make sure everything is 32 bit. (there actually isn't a 64 bit build for PHP-Windows).

hope that helps.
mark

Mark, The extensions being used are those downloaded as part of the version 5.2.14
I chose to use this version because the installation file with the version 5.3 lists files php5ts.dll & libmysql.dll which I couldn’t find in the files downloaded, just enough to put me off.

The php.ini file needs to be in the same directory as the phpcgi.exe.

Your php install might be kind of borked. If possible you may consider unregistering php in IIS with the PHP manager (make sure it is not appearing in the Fast CGI module in IIS too just in case).

Then go pull PHP from http://windows.php.net/download/, and either run the MSI installer (select FastCGI option) or unzip it into a directory like C:\php\ and then registering that with PHP Manager for IIS. Then try this again.

You really shouldn’t have to modify anything in php.ini to run php in IIS. It should just work.

btw, make sure you have the right version of PHP 5.2.14 or 5.3.3 for this project. There may be some incompatibility with this sample exercise and PHP but I can’t be sure. No matter what however, for Windows/IIS you must use the VC9 NTS builds. Don’t use the thread safe or VC6 versions.

hope that helps.
Mark

Hi Mark, OK I will go with your suggestion and uninstall php & unregestering in iis however running the PHP Manager for IIS is where I got the Fast CGI module in IIS from last time so what should this have been doing and how do I avoid Fast CGI module in IIS?
Edward.

Hi Mark, have removed PHP and unregistered IIS OK.
Have replaced PHP file from zip download to C:\php and registered IIS using PHP Manager in IIS all looks good I even have php 5.2.14 as my Handler Mapping resource and all extensions are not enabled. OK.
Have run the website and un fortunately still have a 500 Error showing.
Any further suggestions?
Is there a problem with Authentication? Only Anonymous is enabled?

Not sure I understand your question. Fast CGI != PHP Manager. FastCGI is the host for PHP just like CGI used to be. PHP Manager is just a config tool for PHP on IIS.

You shouldn’t need to disable any extensions. I would undo that step. btw, when enabling/disabling extensions you should do this in PHP Manager, much easier.

I can’t see how Auth would affect this.

Can you send me a link to where I can download this sample app you are running? I want to try it myself. See if I can find the problem.

Thanks Edward.

$product = new Ch2_Product();

you need Ch2_Product(); to be already set.