php XAMPP - “此网页不可用”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28508774/
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
XAMPP - "This webpage is not available"
提问by Gil
I am trying my first Hello World app using php and xampp. I've been getting errors so far and been working through the problems one by one. So far I have:
我正在使用 php 和 xampp 尝试我的第一个 Hello World 应用程序。到目前为止,我一直在遇到错误,并且正在一一解决问题。到目前为止,我有:
Saved the php file ("hello.php") on C:\xampp\htdocs. The following line is in between html "body" tags.
<?php echo '<p>Hello World</p>'; ?>
- Disabled World Wide Web Services from using port 80 as that caused an error on my xampp control panel.
- Disabled mySQL56 from using port 3306 as also caused an error on my xampp control panel. At this point, when I turn on xampp control panel, everything looks fine (I say this because all i can see is blue and black writing) except it says I am not running with admin rights.
- When I type in http://localhost/hello.phpon either Chrome or Firefox, I get "This webpage is not available." error.
将 php 文件(“hello.php”)保存在 C:\xampp\htdocs 上。以下行位于 html“body”标签之间。
<?php echo '<p>Hello World</p>'; ?>
- 禁用万维网服务使用端口 80,因为这会导致我的 xampp 控制面板出现错误。
- 禁用 mySQL56 使用端口 3306 也导致我的 xampp 控制面板出错。在这一点上,当我打开 xampp 控制面板时,一切看起来都很好(我这么说是因为我只能看到蓝色和黑色的文字),除了它说我没有以管理员权限运行。
- 当我在Chrome 或 Firefox 上输入http://localhost/hello.php时,我得到“此网页不可用”。错误。
Does anyone know what I am doing wrong?
有谁知道我做错了什么?
Further notes: I am using Windows 7 and haven't downloaded anything from PHP.
进一步说明:我使用的是 Windows 7 并且没有从 PHP 下载任何东西。
I apologise for perhaps a too wide question. I have tried to be as specific as possible by outlining all actions I have taken.
我为一个太宽泛的问题道歉。我试图通过概述我采取的所有行动来尽可能具体。
采纳答案by Ivaylo Kehayov
Try running control panel with admin rights. Right click on control panel icon and select "Run as administrator". Also it would help if you pasted here the messages that you get in control panel when you start apache (mysql is not needed to run your hello.php file since you don't access any database).
尝试以管理员权限运行控制面板。右键单击控制面板图标并选择“以管理员身份运行”。如果您将启动 apache 时在控制面板中获得的消息粘贴到此处也会有所帮助(运行 hello.php 文件不需要 mysql,因为您不访问任何数据库)。
回答by jave.web
If admin privileges did not work for you, and you are SURE that your firewall or some other appis NOT blocking Apache... then:
如果管理员权限对您不起作用,并且您确定您的防火墙或其他一些应用程序没有阻止 Apache...那么:
Make sure, you are visiting the same port, that your Apache is listening to...
确保您访问的是 Apache 正在侦听的同一端口...
Basic http://localhost/is actually requesting port 80
Secure https://localhost/is requesting port 443
基本的http://localhost/实际上是请求端口 80
安全https://localhost/正在请求端口 443
So in Control Panel, check what ports are 'on' for Apache:
Usually the first one of 2 ports is the one you want - if there is 80, use http://localhost/,
if there is 443, you would use https://localhost/
因此,在控制面板中,检查 Apache 的“开启”端口:
通常 2 个端口中的第一个是您想要的 - 如果有 80,请使用http://localhost/,
如果有 443,您将使用https ://本地主机/
...and lastly - if there is NONE of these 2, you need to write your URL like:
http://localhost:PORT_NUMBER
...最后 - 如果没有这两个,你需要写你的 URL,如:
http://localhost:PORT_NUMBER
I hope this will help someone :)
我希望这会帮助某人:)
回答by Sithara
If you have changed the port numbers of Apache when configuring XAMPP,
如果您在配置 XAMPP 时更改了 Apache 的端口号,
you have to run the localhost as,
你必须运行本地主机,
ex: 89 is the port number.So it can be written as localhost:89
例如:89 是端口号,所以可以写成 localhost:89
You can find the allocated port number from XAMPP control panel.XAMPP Control Panel
您可以从 XAMPP 控制面板中找到分配的端口号。XAMPP 控制面板
回答by Tacticus
I've actually also had quite some issues with XAMPP now, so I bet it's a problem with the software setup. Here are some reasons that could cause your roblem.
我现在实际上也遇到了一些关于 XAMPP 的问题,所以我敢打赌这是软件设置的问题。以下是一些可能导致您的问题的原因。
- Try the local URL http://127.0.0.1/hello.php
- Check the XAMPP control panel to see if Apache is running properly
- Restart your computer
- Run Apache with Administrator privileges
- Check the Apache server configuration
- 尝试本地 URL http://127.0.0.1/hello.php
- 检查 XAMPP 控制面板以查看 Apache 是否正常运行
- 重启你的电脑
- 以管理员权限运行 Apache
- 检查Apache服务器配置
Some less probable causes
一些不太可能的原因
- Make sure no Firewall or other software is blocking the applications, specifically port 80 [e.g., Skype may do that; can be disabled in a menu]. You might want to try out Windows Firewall to try it out ( make sure to reenable it afterwards )
- Check the
hosts
file inC:\Windows\System32\drivers\etc
- 确保没有防火墙或其他软件阻止应用程序,特别是端口 80 [例如,Skype 可能会这样做;可以在菜单中禁用]。您可能想尝试使用 Windows 防火墙进行尝试(确保之后重新启用它)
- 检入
hosts
文件C:\Windows\System32\drivers\etc
Alternatively, try connecting to the standard XAMPP page located at the local website roots localhost
/ 127.0.0.1
.
或者,尝试连接到位于本地网站根目录localhost
/的标准 XAMPP 页面127.0.0.1
。