prompt to download php file

Configuring PHP to run on IIS is usually a relatively straight forward task, but as there are many steps when configuring your server it can be a real pain to back track your steps when something goes wrong. Being prompted to download a php file or having your browser window fill with PHP code rather than it being processed by your server are among the most common problems encountered when configuring PHP on IIS. In this article we'll look at some possible causes and resolutions.

1. Check, double check and triple check your PHP application mapping in IIS. The single biggest cause of being prompted to download a PHP file rather than it being processed by IIS is that the PHP application mapping is not set correctly. Make sure that the path to the PHP DLL or CGI executable is correct (also ensure there are no spaces), the PHP application mapping is set to use the .php extension, at least the GET, HEAD and POST verbs are enabled, and that the "script engine" and "check file exists" options are checked. If in doubt, have a look at this on installing PHP 5 on IIS in 5 simple steps which is complete with screen shots.

2. Check your PHP scripts for usage of short tags. Quite often PHP scripts will be written using the short style tag. This will be the very first line in your PHP script, and if they use this then you'll need to enable the short_open_tag directive in php.ini.

3. Check if the PHP scripts your trying to run are in a sub or virtual directory. Because IIS ScriptMaps can be configured to run at global, site, directory and virtual directory level it is possible that not all sections of your site are capable of processing PHP scripts. If you can run a PHP script in one directory and it does not run when you move it to another directory, then you'll need to contact your host to establish where your PHP scripts should be located for correct operation.

4. Check the default_mimetype directive in php.ini. Make sure the mimetype for PHP is set to "text/html" in php.ini using the default_mimetype directive. It may also be worth inspecting your IIS configuration to ensure that a mimetype for PHP has not been set there.

5. Check your PHP scripts for usage of ASP style tags. I've never seen this myself, but if a PHP script where to use the ASP style tags then asp_tags directive in php.ini will need to be enabled.

Hopefully after inspecting your PHP environment for the points above you have managed to get it working. Feel free to comment or post a thread in the forums if you have any questions or comments.


Average rating
(0 votes)
|
Submitted by Dominic Ryan on Wed, 2007-11-21 00:00.

Post new comment

  • Use <!--pagebreak--> to create page breaks.
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use BBCode tags in the text, URLs will automatically be converted to links.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Copy the characters (respecting upper/lower case) from the image.