php http://localhost/ 在 Windows 7 上不工作。有什么问题?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/813347/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
http://localhost/ not working on Windows 7. What's the problem?
提问by AXheladini
I have a big problem opening http://localhost/on Windows 7 (beta). I installed this os and everything went great; when I installed Wamp I saw that localhost is not working at all. I just see this error:
我在 Windows 7(测试版)上打开http://localhost/时遇到了一个大问题。我安装了这个操作系统,一切都很好;当我安装 Wamp 时,我看到 localhost 根本不起作用。我只看到这个错误:
Failed to Connect
Firefox can't establish a connection to the server at localhost.
连接失败
Firefox 无法与 localhost 上的服务器建立连接。
in Mozilla and Explorer.
在 Mozilla 和 Explorer 中。
I removed Wamp and after some weeks (that means two weeks from today) I installed NetBeans on Windows 7. I created a test PHP script and when I debug it, I get the same error again. I tried to access it with ip 127.... but still the same. What is the problem?
When i installed NetBeans I installed it in port 8080.
我删除了 Wamp,几周后(这意味着从今天起两周)我在 Windows 7 上安装了 NetBeans。我创建了一个测试 PHP 脚本,当我调试它时,我再次遇到相同的错误。我试图用 ip 127 访问它......但还是一样。问题是什么?
当我安装 NetBeans 时,我将它安装在端口 8080 中。
采纳答案by fabio
To fix the port 80 problem do:
要修复端口 80 问题,请执行以下操作:
From cmd as administrator:
从 cmd 以管理员身份:
sc config http start= demand(you need a space after the equal sign and not before)- Reboot
- Run the command (
netsh http show servicestate) as administrator to check that the port 80 is in use
sc config http start= demand(你需要在等号之后而不是之前有一个空格)- 重启
netsh http show servicestate以管理员身份运行命令 ( ) 以检查端口 80 是否正在使用中
After you have run this command, you can disable http.sys as follows:
运行此命令后,您可以禁用 http.sys,如下所示:
net stop http(stop the process)Sc config http start= disabled(if you want to disable the service forever)
net stop http(停止进程)Sc config http start= disabled(如果您想永久禁用该服务)
it works for me.
这个对我有用。
回答by FlySwat
If you installed it on port 8080, you need to access it on port 8080:
如果安装在8080端口,则需要在8080端口访问:
回答by fabio
Edit your C:\Windows\System32\drivers\etc\hostsfile
编辑您的C:\Windows\System32\drivers\etc\hosts文件
Make sure there is an entry that looks like this:
确保有一个看起来像这样的条目:
127.0.0.1 localhost
If there is an entry like
如果有像这样的条目
:: localhost
Comment it out to look like this
注释掉它看起来像这样
\#:: localhost
This should fix your problem, I've had this problem in the past.
这应该可以解决您的问题,我过去遇到过这个问题。
回答by fabio
For me, it was skype causing the problem. Once I stopped skype, everything worked. I have 1.7.1 xampp (mysql and apache) running on Windows 7 x64.
对我来说,是Skype导致了问题。一旦我停止了Skype,一切正常。我有 1.7.1 xampp(mysql 和 apache)在 Windows 7 x64 上运行。
回答by BenB
It sounds like you have no web server running at all anywhere.
听起来您根本没有在任何地方运行 Web 服务器。
Have you tried enabling IIS and using it to display a basic html file first?
您是否尝试过启用 IIS 并使用它首先显示基本的 html 文件?
Programs & Features -> Turn Windows Features On/Off -> Internet Information Servcies
程序和功能 -> 打开/关闭 Windows 功能 -> Internet 信息服务
Then, place your html file in C:\inetpub\wwwroot\index.html and browse to http://localhost.
然后,将您的 html 文件放在 C:\inetpub\wwwroot\index.html 并浏览到http://localhost。
Once this works, try to get WAMP/php working. Be careful of port conflicts.
一旦成功,请尝试让 WAMP/php 工作。小心端口冲突。
回答by Richard
My initial thought is that you are missing an entry in the hosts file. Something like "127.0.0.1 localhost", however, you mention that you are getting a 404 error. That means that the webserver is connecting to your client/browser and responding to the request for a particular webpage.
我最初的想法是您缺少主机文件中的条目。然而,像“127.0.0.1 localhost”这样的东西,你提到你收到了一个 404 错误。这意味着网络服务器正在连接到您的客户端/浏览器并响应对特定网页的请求。
I'm not familiar enough with Windows 7, however, I'm pretty sure that it does not include a webserver by default. Also, unless you actually code, build and run a webserver application using netbeans you're not going to get the desired response.
我对 Windows 7 不够熟悉,但是,我很确定它默认不包含网络服务器。此外,除非您实际使用 netbeans 编写、构建和运行网络服务器应用程序,否则您将无法获得所需的响应。
When it comes down to it.... your issue is going to be one of the following:
归根结底……您的问题将是以下问题之一:
1) you're serving static documents and the webserver is not configured to serve the files from whatever the proper DOCROOT should be. This includes PUBLIC folders in the user's directories. (the basic apache install include a basic homepage)
1)您正在提供静态文档,并且网络服务器未配置为从正确的 DOCROOT 中提供文件。这包括用户目录中的 PUBLIC 文件夹。(基本的 apache 安装包括一个基本的主页)
2) you have a dynamic webserver application where the controller is looking at the application path in order to decide what page to display or what function to execute. (see MVC - Controller). Basically incomplete implementation.
2) 您有一个动态 Web 服务器应用程序,其中控制器正在查看应用程序路径,以确定要显示的页面或要执行的功能。(请参阅 MVC - 控制器)。基本实现不完整。
3) yet another configuration error: your website might actually define a virtual domain. (something other than localhost) so when you look for localhost in the URL the server might not be configured to provide a default page.
3) 另一个配置错误:您的网站实际上可能定义了一个虚拟域。(除 localhost 之外的其他内容)因此当您在 URL 中查找 localhost 时,服务器可能未配置为提供默认页面。
回答by Abid
Uncommenting the following line in host file worked for me,
取消注释主机文件中的以下行对我有用,
#127.0.0.1 localhost
回答by Matt
Well you are getting a 404, so the web server is running, it just can't find the file.
好吧,您收到了 404,因此 Web 服务器正在运行,只是找不到该文件。
Check the http.conf file. If it pointing to the right root directory?
检查 http.conf 文件。如果它指向正确的根目录?
If you are using different ports, then check http.conf to see if Apache is listening on the right port, or if apache is redirecting traffic on the port to anther root directory.
如果您使用不同的端口,请检查 http.conf 以查看 Apache 是否正在侦听正确的端口,或者 apache 是否正在将端口上的流量重定向到另一个根目录。
Maybe posting your http.conf file might help?
也许发布您的 http.conf 文件可能会有所帮助?
回答by The Master Prawn
Yea, this was a pain for me as well.
是的,这对我来说也是一种痛苦。
So what i did was find the "Start Wampserver", just hit the start button and type it in.
所以我所做的是找到“启动 Wampserver”,只需点击开始按钮并输入即可。
Then right click on it , select properties. I set it to run in XP servive pack 3 on the capatability tab. I also checked the box "Run this program as an administrator".
然后右键单击它,选择属性。我将它设置为在能力选项卡上的 XP servive pack 3 中运行。我还选中了“以管理员身份运行此程序”框。
Then I right clicked the WAMPSERVER on the System Tray, and re-started all services. This worked perfect for me, hope this will help you as well.
然后我右键单击系统托盘上的 WAMPSERVER,并重新启动所有服务。这对我来说很完美,希望这也能帮助你。
Rob
抢
回答by The Master Prawn
Got any other Programs running ? msn ect... ? some bind to port 8080 then your webserver wouldnt start and would cause a 404 , try binding it to a different port 80 which its default should be
有没有其他程序正在运行?msn 等...?一些绑定到端口 8080 然后你的网络服务器不会启动并导致 404 ,尝试将它绑定到不同的端口 80 ,它的默认值应该是

