php files downloading instead of opening

3

I have a Windows 7 laptop. I downloaded PHP 5.2.8. I downloaded Apache 2.2.

I ran the MSI for PHP install, which i know is not recommended but I tried multiple times the normal route without success.

I have apache running and it shows "Running all apache services". When i did the install i set it up for "localhost".

I checked the CGI checkbox in my control panel.

I placed a simple file, test.php , in C:\inetpub\wwwroot ... but when the file is double-clicked, it tries to download the file instead of opening it as a webpage.

I've been googling this for a couple of hours and cant find a suitable fix. I have cleared my cache, and still no luck.

I also set apache to listen on port 8080 just to be certain nothing else was using port 80 before hand.

Any Ideas??

Thanks!


update -- i was missing the php5apache2.dll ... i placed this in the PHP directory but still the same results. i have also tried browsing to the file location through IE which didnt change anything either unfortunately.


update again, - - DOH! - - didnt realize it was localhost/test.php or what the answer below was. when i do that, i get a server error page.. which is better than before i guess :)

Server Error in Application "DEFAULT WEB SITE"

HTTP Error 500.0 - Internal Server Error

An unknown FastCGI error occured

Module FastCgiModule 

Notification ExecuteRequestHandler 

Handler PHP 

Error Code 0x8007010b 

Requested URL http://localhost:80/test.php

Physical Path C:\inetpub\wwwroot\test.php 

Logon Method Anonymous 

Logon User Anonymous 

Most likely causes:

•IIS received the request; however, an internal error occurred during the processing of the request. The root cause of this error depends on which module handles the request and what was happening in the worker process when this error occurred.

•IIS was not able to access the web.config file for the Web site or application. This can occur if the NTFS permissions are set incorrectly.

•IIS was not able to process configuration for the Web site or application.

•The authenticated user does not have permission to use this DLL.

•The request is mapped to a managed handler but the .NET Extensibility Feature is not installed.

when i try to start/run apache, it errors out. so when i run apache test configuration i get the following message: httpd.exe: Syntax error on line 1 of C:/Apache/conf/httpd.conf: Cannot load C:/php/php5apache2_2.dll into server: The specified module could not be found.

However when i browse to that director, i do see that dll file there!! ugh...

ideas?

php
apache
iis
windows-7
installation
asked on Stack Overflow Sep 16, 2011 by Adam • edited Sep 16, 2011 by (unknown user)

3 Answers

2

If you placed a file called test.php in C:\inetpub\wwwroot, then you would open your browser to http://localhost/test.php to try to execute the file.

The php5apache2.dll file needs to go in your module directory for apache, and you would need to add the appropriate apache config lines such as those below:

LoadModule php5_module "c:/path/to/php5apache2.dll"

AddHandler application/x-httpd-php .php

SetHandler application/x-httpd-php

After making those changes, you will need to restart apache.

answered on Stack Overflow Sep 16, 2011 by drew010 • edited Sep 16, 2011 by drew010
1

Assuming you have PHP installed in Apache properly as mentioned in the other answers, it is possible the .php page is not sending the correct header. I have a .php file that emits a header with Content-Type: text/json, this is commonly used to provide a service for an Ajax client. The .php page should be sending Context-Type: text/html.

To determine if this is indeed the problem you can use wget with the -S option, or use developer tools in your browser. Take a look at this answer: Tool to view response headers

answered on Stack Overflow Mar 1, 2013 by focused4success • edited May 23, 2017 by Community
0

Double clicked? As in within explorer? If so, this won't open the page. You need to browse to the page. If you're within the directory listing for apache double clicking is not necessary.

As for setting up, if you're new your best bet is to use iis, easyphp, xampp, or some other variation

They'll get you running without the hassle

answered on Stack Overflow Sep 16, 2011 by Howard Lince III

User contributions licensed under CC BY-SA 3.0