weasel7711 0 Junior Poster in Training

I had followed a tutorial on installing PHP on IIS 7 for Windows Server 2008 and changed the path to reflect my location of PHP.

http://www.howtogeek.com/50432/how-to-install-php-on-iis-7-for-windows-server-2008/

I can use the command line to execute php, and I can run php files using localhost, however I cant run the troubleshooting command
<?php phpinfo(); ?>, as I get a 500 error. I can do it through the command line and it outputs but not through localhost on IE.


------------------------------------------------

SOLVED!

I was piping the results of the "php D:\www\phpinfo.php" file to a text file so I could post it here. I noticed an error that had previously been hidden at the beginning of the output.

PHP Warning: phpinfo(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for '-4.0/DST' instead in D:\www\phpinfo.php on line 1

Apparently someone...

*ahem*

...hadn't uncommented the time zone in the php.ini file.

Everything works now.

Dani AI

Generated

Good catch by — the root cause was a PHP startup warning about an unset timezone being emitted before HTTP headers. Under IIS/FastCGI any text sent prior to a valid header can break the CGI response and show a 500. The practical fix is to set a valid timezone in the php.ini that the web server uses (not just the CLI one), then restart the IIS worker process.

Quick actionable steps:

  1. Confirm which php.ini the web server loads (check the web-accessible PHP info page).

  2. Edit that php.ini and set a valid timezone, for example:

    date.timezone = "UTC"
  3. Save and restart the application pool or IIS so the change takes effect.

  4. In production, keep display_startup_errors and display_errors off and use an error log to capture warnings instead of letting them appear in output.

If the 500 persists: verify the PHP error log and Windows Event Viewer for FastCGI/IIS messages, and confirm the web PHP and CLI PHP are using the same configuration file. You can also disable display of startup errors while logging them to a file to prevent early output from corrupting HTTP headers.

Useful references: PHP configuration for timezones and the phpinfo function are documented here:
datetime.configuration.php - PHP manual
phpinfo() - PHP manual

These checks prevent subtle startup warnings from being sent to the browser and avoid IIS returning a generic 500 when PHP emits output before headers.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.