Wednesday, June 25, 2008

Apachelounge

If you use the Apache MSI package and are looking for a portable Apache ZIP package, which you can just unpack and install, look for it on apachelounge.com. These guys maintaining alternative Apache distribution package that can be unpacked and started from your USB flash drive in seconds.

Friday, June 13, 2008

See real script error hidden by "The webside cannot display the page"

When you see in your browser "The website cannot display the page" error message like this:



And want to discover a "real" error, just click Tools -> Internet Options, then clear the "Show friendly HTTP error messages" check box on the "Advanced" tab and click Ok.



Then just refresh the page.

Thursday, June 12, 2008

Starting PHP CLI with custom PHP.ini

If you HTTP server PHP configuration is different from PHP command line configuration and this prevents you from using PHP CLI, you can resolve this by creating different version of the PHP.ini and specify it when you call the PHP.exe from the command line. You can specify the PHP.ini in one of the following ways:
  • Using PHPRC environment variable. This tutorial will help you to modify environment variables on Windows.
  • With -c command line PHP.exe switch as follows:
    C:\> C:\PHP5\php.exe -c C:\PHP5\PHP.CLI.ini script.php

Wednesday, May 28, 2008

How to change default documents on IIS7 (Vista, Server 2008)

Using the appcmd command you can view, add and delete default documents in IIS configuration.

View:
C:\> %SystemRoot%\system32\inetsrv\appcmd list config /section:system.webServer/defaultDocument

Add:
C:\> %SystemRoot%\system32\inetsrv\appcmd set config /section:system.webServer/defaultDocument /+files.[value='index.php']

Remove:
C:\> %SystemRoot%\system32\inetsrv\appcmd set config /section:system.webServer/defaultDocument /-files.[value='index.php']

Friday, May 23, 2008

PHP as Apache module vs. PHP via Apache FastCGI

apachelounge.com members share very interesting results of their experiment with different PHP configurations.

Light blue line: httpd.exe processes Memory Usage
Dark blue line: all processes Memory Usage total
Fri-Sun : mod_fcgid
Mon-Tue : module with php from php.net (VC6)
Wed-Thu : module with self build php (VC9)
Fri : mod_fcgid



Link

Thursday, May 22, 2008

How to specify PHP.ini for IIS5.1 and IIS6 FastCGI

The specific PHP.ini can be specified in the "Arguments" IIS FastCGI configuration option as follows:

[Types]
php=PHP-5.2
[PHP-5.2]
ExePath=C:\path\to\php-cgi.exe
Arguments=-c C:\path\to\php.ini

You can open the FastCGI configuration file by opening Windows command prompt and executing the following command:

notepad C:\WINDOWS\system32\inetsrv\fcgiext.ini

Wednesday, May 21, 2008

Troubleshooting "Fatal error: Maximum execution time exceeded" in PHP

The "Fatal error: Maximum execution time of [some number] seconds exceeded in [php file name] on line [some number]" error message indicates that the called PHP script reach the time limit and was terminated by the PHP language engine. There are number of reasons for that and most common of them are:
  • Sending a lot of queries to a database.
  • Some particular database query requires a lot of time to complete.
  • Script has a lot of data to process.
  • Defect in script code.
If you are the script developer, you can profile it and fix bottlenecks. If you an administrator, you can try to increase PHP script time limit in PHP.ini by increasing the value of the max_execution_time option (in seconds) or call the set_time_limit function at the very top of the script in a PHP code block.

Examples:
  • PHP.INI: max_execution_time = 600
  • PHP script:
  • .htaccess: php_value max_execution_time 600