VerySimple Developer Blog
Technical Tips, Tricks and Rants.

Archive for the ‘PHP’ Category

 
Mar
30
Filed Under (Apache, IIS, PHP) by Jason on 30-03-2006

Installing PHP to run on Windows through IIS is pretty simple because there is an installation wizard that does everything for you. But, those of us who also have Apache running for development need to have Apache process PHP pages too. This is a walkthrough to get both running.

This will run PHP in CGI mode for both IIS and Apache.

1. Download from www.php.net the Windows Installer version of PHP AND the Windows “manual install” .zip distribution. (If you already have PHP running for IIS, then you only need the zip version)

2. Run the PHP installer. Install it to its default location of C:\PHP. PHP should now be working with IIS.

3. Move the file C:\PHP\php.ini-dist to C:\Windows\php.ini

3. Unzip the “manual install” distribution. You’ll notice that it has much of the same files as are already in C:\PHP. Move all the of extra directories contained in this .zip to C:\PHP

4. Download and install Apache HTTP server from www.apache.org. (I used version 2). Default install location is C:\Program Files\Apache Group\Apache2. The configuration you use is up to you, but i specify in the install wizard to run Apache manually on port 8080 so that it will co-exist with IIS (which is already on port 80). Then after that is done, I install it as a service by executing the command-line command: apache -k install
(from within the apache2\bin directory)

5. Edit the Apache configuration file C:\Program Files\Apache Group\Apache2\httpd.conf - make the following changes:

# search for “DirectoryIndex” and add index.php to the end:
DirectoryIndex index.html index.html.var index.php

# search for “ScriptAlias” and add the following lines in that section:
ScriptAlias /php/ “c:/php/”
AddType application/x-httpd-php .php
Action application/x-httpd-php “/php/php.exe”

6. restart Apache and the new configuration should take effect. create a test PHP file and see how it works.

* caveat: if you use the same browser and surf back-and-forth between IIS and Apache, you may get a bunch of weird error messages about permission denied while writing session files. This is because Apache and IIS run as different users & they will block each other from writing to the same session file.

 

 
Mar
30
Filed Under (PHP) by Jason on 30-03-2006

When PHP is processing a file upload and you receive the error message “Fatal error: Maximum execution time of 30 seconds exceeded” it is because the script has timed out. I was working on an application where this was occuring during a file upload. The entire file would be uploaded, then the error would be displayed

All over the web, you find people telling you to call set_time_limit() on the upload page. This overrides the max_execution_time setting which is found in php.ini. Calling this function on my upload page seems to have no effect on my server.

Changing max_execution_time in php.ini to 0 is supposed to be an unlimited timeout. However i was still receiving the error message. It would say “Fatal error: Maximum execution time of 0 seconds exceeded” which does not make any sense to me at all.

I discovered that, in addition to the max_input_time which controls how long a php file can spend processing the request data.

When i set max_input_time to a higher value, the problem goes away. So, it appears that the error message is reporting the wrong configuration variable.

PHP 4.3.4.4
Apache 2.0
Windows XP Pro SP1

 

 
Mar
30
Filed Under (*NIX, Apache, PHP) by Jason on 30-03-2006

There is a problem with IE and PHP applications is certain instances where an intermittent blank page appears instead of the expected content.

This seems to relate to an earlier bug reported by Microsoft with IE 6 where the content length was reported as 0 during POST requests. This occured when browsing sites running UNIX/Apache with keepalive enabled. However, I’ve discovered that the same problem occurs intermittently with certain PHP applications and GET requests.

One workaround which solves the problem (although with a performance hit) is to create an .htaccess file in the root directory with the following setting:

[code]
BrowserMatch “MSIE” nokeepalive downgrade-1.0 force-response-1.0

SetEnvIf User-Agent “.*MSIE.*” \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
[/code]

This workaround disables keepalive for all IE 6 clients. I imagine this would have a negative performance effect, however it is likely preferable to a buggy application.

I haven’t been able to determine if certain PHP code techniques could be causing the problem. I read certain people presuming that it could be session related, however, i went as far as removing all session functionality from an application, however it did not solve the problem.

 

« Previous Entries Next Entries »
Close
  • Social Web

NOTE: Email is disabled

E-mail It