运行php文件要求下载而不是在apache 2.5中执行?
我有一个Windows7 64bit,我试图运行php,而我的IE浏览器要求我下载文件而不是执行它.有人告诉我下载apache,所以我降低了wamp2.5-32bit版本的安装范围,并安装了好软件,并选择Firefox作为wamp的默认设置.但是仍然当我双击wamp的www目录中的php文件时,firefox要求我下载它而不是运行它.
I have a windows7 64bit, I tried to run php and my IE browser was asking me for to download the file instead of executing it. Someone told me to download apache, so i downoaded wamp2.5-32bit version, installed it well, and also chose Firefox as default for wamp. But still when I double click php files in www directory of wamp, firefox asks me to download it instead of running it.
我尝试将这些行添加到httpd.conf中,但没有更改;
I have tried adding these lines in httpd.conf but no change;
LoadModule php5_module "c:/wamp/bin/php/php5.5.12/php5apache2_4.dll"
#PHPIniDir c:/wamp/bin/php/php5.5.12
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
AddType text/html .php
LoadModule php5_module modules/mod_php55.so
这个wamp选项似乎也像战争的标签,我正在编辑记事本文件,现在已经花费了很多时间.还有其他选择吗?
This wamp option also seems like a tag of war, I am going around editting notepad files and its now lots of hours gone. Is there another option?
马特,
如果您浏览httpd.conf
,您会发现所有您说已添加的行已经存在于适当的位置.
If you look through httpd.conf
you will find all of those lines you say you have added already exist in there proper place already.
假设您还进行了一些其他忘记或未提及的更改,建议您卸载WAMPServer(使用标准的Windows卸载机制)
Assuming you have also done some other changes you have forgotten about or not mentioned I would suggest you Uninstall WAMPServer (using the standard windows uninstall mechanism )
然后手动删除c:\wamp
,因为您编辑的所有文件都不会被卸载删除.
Then manually delete c:\wamp
as any files you have edited will not be removed by the uninstall.
现在重新安装WAMPServer.
Now reinstall WAMPServer.
全新安装后,WAMPServer的wampmanager图标为绿色,在浏览器中输入
Once you have a fresh install and WAMPServer's wampmanager icon is green enter this in your browser.
http://localhost
如果您看到WAMPServer主页,则表明PHP正在运行,因为此页面是用PHP编写的.
If you see the WAMPServer homepage then PHP is working, as this page is written in PHP.
现在您说您是double clicking
文件夹中的文件名,因此,我假设您是在使用Explorer
并双击文件名! 不要这样做,这只会在浏览器中启动该文件,而不会通过Apache运行该文件.如果您只有HTML& Javascript页面,但不会编译和运行PHP脚本.
Now you say you are double clicking
a filename in the \wamp\www
folder, by this I assume you mean you are using Explorer
and double clicking a filename! DONT DO THAT That will just launch this file in the browser but will not run the file through Apache. That method is ok if you just have a HTML & Javascript page, but it will not compile and run a PHP script.
要使PHP脚本运行,您必须通过Apache运行页面,以便它可以识别<?php
标记.然后,Apache知道通过PHP传递脚本,以便可以对其进行解释和执行.
To get a PHP script to run you must run the page through Apache so it can spot the <?php
tag. Apache then knows to pass the script through PHP so it can be interpreted and executed.
为此,您可以在浏览器地址栏中输入url,就像启动StackOverflow页面一样:-
So to make this happen you enter the url into the browsers address bar like you would to launch the StackOverflow page like so :-
localhost/project1/text.php