为什么我的本地 Apache 无法打开 html 页面?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/60213/
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
Why won't my local Apache open html pages?
提问by Baltimark
so, I'm running Apache on my laptop.
所以,我在我的笔记本电脑上运行 Apache。
If I go to "localhost", I get the page that says,
如果我去“本地主机”,我得到的页面说,
If you can see this, it means that the installation of the Apache web server software on this system was successful. You may now add content to this directory and replace this page.
如果你能看到这个,就说明在这个系统上安装了Apache web服务器软件是成功的。您现在可以将内容添加到此目录并替换此页面。
except, I can't add content and replace that page.
除了,我无法添加内容并替换该页面。
I can click on its links, and that works fine.
我可以点击它的链接,而且效果很好。
First of all, there's not even an "index.html" document in that directory. If I try to directly access one that I created with localhost/index.html, I get "the request URL was not found on the server." So, I'm not even sure where that page is coming from. I've searched for words in that page under the apache directory, and nothing turns up. It seems to redirect somewhere.
首先,该目录中甚至没有“index.html”文档。如果我尝试直接访问我用 localhost/index.html 创建的一个,我会得到“在服务器上找不到请求 URL”。所以,我什至不确定那个页面来自哪里。我在 apache 目录下的那个页面中搜索了单词,但没有任何结果。它似乎重定向到某个地方。
Just as a test, I KNOW that it loads localhost/manual/index.html (doesn't matter what that is) so I tried to replace that with something I've written, and I received the message
作为测试,我知道它加载了 localhost/manual/index.html(无关紧要)所以我尝试用我写的东西替换它,然后我收到了消息
The server encountered an internal error or misconfiguration and was unable to complete your request.
服务器遇到内部错误或配置错误,无法完成您的请求。
The error log says,
错误日志说,
[Fri Sep 12 20:27:54 2008] [error] [client 127.0.0.1] Syntax error in type map, no ':' in C:/Program Files/Apache Group/Apache2/manual/index.html for header \r\n
[2008 年 9 月 12 日星期五 20:27:54] [错误] [客户端 127.0.0.1] 类型映射中的语法错误,C:/Program Files/Apache Group/Apache2/manual/index.html 中没有“:”头文件 \ r\n
But, that page works fine if I open directly with a browser.
但是,如果我直接使用浏览器打开该页面,则该页面工作正常。
so, basically, I don't know what I don't know here. I'm not sure what apache is looking for. I'm not sure if the error is in my config file, my html page, or what.
所以,基本上,我不知道我在这里不知道什么。我不确定 apache 正在寻找什么。我不确定错误是在我的配置文件、我的 html 页面还是什么。
Oh, and the reason I want to open this using apache is (mainly) because I'm trying to test some php, so I'm trying to get apache to run locally.
哦,我想使用 apache 打开它的原因(主要)是因为我正在尝试测试一些 php,所以我试图让 apache 在本地运行。
Thanks.
谢谢。
采纳答案by cschol
"By default, your pages should be placed in the "C:\Program Files\Apache Group\Apache2\htdocs" folder for Apache 2.0 and the "C:\Program Files\Apache Software Foundation\Apache2.2\htdocs" folder for Apache 2.2. When your site is ready, simply delete the existing files in the folder and replace them with those you want to test."
“默认情况下,对于 Apache 2.0,您的页面应放在“C:\Program Files\Apache Group\Apache2\htdocs”文件夹中,对于 Apache 2.0 应放在“C:\Program Files\Apache Software Foundation\Apache2.2\htdocs”文件夹中。 Apache 2.2。当您的站点准备就绪时,只需删除文件夹中的现有文件并将其替换为您要测试的文件即可。”
From here.
从这里开始。
回答by Baltimark
OK,
好的,
To answer my own. . .I found that the "Listen" directive in the configuration file had been set to "Listen 80" instead of "Listen localhost: 80".
来回答我自己。. .我发现配置文件中的“Listen”指令已设置为“Listen 80”而不是“Listen localhost:80”。
Also, localhost/htdocs/index.html doesn't work, but localhost/index.html does.
此外, localhost/htdocs/index.html 不起作用,但 localhost/index.html 起作用。
Hopefully this can help someone in the future.
希望这可以帮助将来的某人。
Thanks, Schroeder.
谢谢,施罗德。
回答by limitcracker
If you have Skype it also uses the same ports(80, 443) as Xampp does. So start Xampp first and then Skype.
如果您有 Skype,它也使用与 Xampp 相同的端口(80、443)。所以先启动 Xampp,然后再启动 Skype。
[source: http://starikovs.com/2011/02/23/apache-doesnt-start-in-xampp/]
[来源:http://starikovs.com/2011/02/23/apache-doesnt-start-in-xampp/]

