PHP文件下载而不是打开
我有一个Windows 7笔记本电脑。我下载的PHP 5.2.8。我下载的Apache 2.2。
I have a Windows 7 laptop. I downloaded PHP 5.2.8. I downloaded Apache 2.2.
我跑了MSI的安装PHP,我知道是不推荐,但我试过多次都没有成功的正常途径。
I ran the MSI for PHP install, which i know is not recommended but I tried multiple times the normal route without success.
我的apache运行,显示运行的所有阿帕奇服务。当我做了我安装它设置为localhost的。
I have apache running and it shows "Running all apache services". When i did the install i set it up for "localhost".
我在控制面板中检查CGI复选框。
I checked the CGI checkbox in my control panel.
我把一个简单的文件,test.php的,在C:\\的Inetpub \\ wwwroot的......但是当文件被双击,它会尝试下载文件,而不是打开它作为一个网页
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.
我还设置Apache监听端口8080上的刚需一定没有别的使用端口80,前手。
I also set apache to listen on port 8080 just to be certain nothing else was using port 80 before hand.
任何想法??
谢谢!
更新 - 我错过了php5apache2.dll ...我放在这个在PHP目录,但还是一样的结果。我也试图通过IE浏览器浏览到该文件的位置而没有改变任何事很遗憾。
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.
再次更新 - - DOH! - - 没意识到这是本地主机/ test.php的还是什么下面的答案是。当我这样做,我得到了一个服务器错误页面..这比以前我猜:)
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
最可能的原因:
•IIS收到了请求;然而,该请求的处理过程中发生了一个内部错误。此错误的根本原因取决于哪个模块处理请求,哪些是在工作进程中发生的事情出现此错误时。
•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无法访问的web.config文件的网站或应用程序。如果NTFS权限设置不正确,就会发生这种情况。
•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无法处理配置的网站或应用程序。
•IIS was not able to process configuration for the Web site or application.
•通过身份验证的用户没有使用此DLL的权限。
•The authenticated user does not have permission to use this DLL.
•请求被映射到托管处理程序,但没有安装.NET可扩展功能。
•The request is mapped to a managed handler but the .NET Extensibility Feature is not installed.
当我尝试开始/运行Apache,就出现了错误。所以,当我运行Apache测试配置我得到以下信息:
httpd.exe:/Apache/conf/httpd.conf:基于C的第1行中的语法错误无法加载C:/php/php5apache2_2.dll到服务器:指定的模块找不到。
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.
然而,当我浏览到导演,我也看到,dll文件存在!唉...
However when i browse to that director, i do see that dll file there!! ugh...
想法?
假设你安装了Apache PHP适当在其他的答案中提到,有可能在PHP页面不发送正确的标题。我有一个发射具有Content-Type的头部中的PHP文件:文本/ JSON,这通常用来提供一个Ajax客户端的服务。在PHP页面应该被发送上下文类型:text / html的
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.
要确定这确实是你可以使用wget和-S选项,或在浏览器中使用的开发工具的问题。看看这个答案:Tool查看响应头
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