php “您的项目”中的链接在 WAMP 服务器中不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25463802/
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
Link in "Your Projects" isn't working in WAMP server
提问by Sani Evans
I'm on windows 8, I downloaded the wamp server and I have my index.php saved into the "www" folder within a subfolder called websites. When I'm on the localhost page, it displays the subfolder under "Your Projects" but when I click it, it takes me here
我在 Windows 8 上,我下载了 wamp 服务器,并将我的 index.php 保存到名为网站的子文件夹中的“www”文件夹中。当我在 localhost 页面上时,它会在“您的项目”下显示子文件夹,但是当我单击它时,它会将我带到这里
http://www.dnsrsearch.com/index.php?origURL=http%3A//websites/&r=http%3A//localhost/
http://www.dnsrsearch.com/index.php?origURL=http%3A//websites/&r=http%3A//localhost/
and it says
它说
"Why Am I Here? You entered an unknown web address that was used to present site suggestions that you may find useful. Clicking any of these suggestions provides you with search results, which may include relevant sponsored links.
“我为什么在这里?您输入了一个未知的网址,该地址用于提供您可能觉得有用的网站建议。单击这些建议中的任何一个都会为您提供搜索结果,其中可能包含相关的赞助商链接。
If this service is not right for you, please visit your Preferences page to opt out. At any point in time, you can opt back in to the service by visiting your Preferences page.
如果此服务不适合您,请访问您的首选项页面选择退出。在任何时候,您都可以通过访问您的首选项页面选择重新加入该服务。
If you have other questions about this service, please visit our FAQ."
如果您对此服务有其他疑问,请访问我们的常见问题解答。”
Basically, it's taking me to a search engine and trying to show some suggestions for what I could've wanted, but I'm not trying to go to a website. I'm trying to access and display my test site so I can start practicing PHP. It's been really frustrating just getting started with this because I've come across all these different ways to do php and different problems and so far, using this wampserver seems like the best option but I'm stuck. Please please pleasehelp. This is driving me nuts!
基本上,它会将我带到搜索引擎并尝试针对我可能想要的内容显示一些建议,但我并不是要访问网站。我正在尝试访问和显示我的测试站点,以便我可以开始练习 PHP。刚开始使用这个真的很令人沮丧,因为我遇到了所有这些不同的 php 方法和不同的问题,到目前为止,使用这个 wampserver 似乎是最好的选择,但我被卡住了。请请帮助。这让我发疯!
Summary: I installed the WAMP server, I have my index.php saved in my www folder with its designated www subfolder (wamp\www\Websites\index.php), it displays on the localhost under my projects, but the link to display it doesn't work.
摘要: 我安装了 WAMP 服务器,我将 index.php 保存在我的 www 文件夹及其指定的 www 子文件夹(wamp\www\Websites\index.php)中,它显示在我的项目下的本地主机上,但显示的链接它不起作用。
Any answers?
任何答案?
FOLLOWING UP A YEAR LATER
一年后跟进
I appreciate the responses I've received. What I ended up doing to get the ball rolling (I went on a web development hiatus to pursue other things) and make things a lot easier to work with is I setup a LAMP server instead and it made the install process super easy and straight forward, and from there I've had no problems at all creating virtual hosts and making my websites work and having everything interact the way it should. If you're stuck where I was, setting up and using WAMP on windows is a lot more involved and touchy than setting it up on a linux system. On a linux system, you won't get a dedicated gui program like WAMP, but you'll have everything running in your operating system to handle it and it basically turns your computer into a local web server with php/sql support, and whatever else you'd like to add onto it. I'm using kali linux and it's working out fine for me. If you just want to dive into php without having to get over the huge hurdle on windows virtual hosts, I highly recommend just doing the research and setting it up on a linux system. If you have an additional hard drive, put linux on it. If you don't, setup a dual boot configuration on your drive so you'll have windows and linux. It helped me out a ton with learning how to make things on the backend reference each other the way I wanted to while also getting a significantly better understanding of it as I went. All you need installed is apache, mysql, and php and after setting everything up, it should work just fine on your local machine. Learning linux can seem scary at first, but this process is a lot more straight forward and easier to understand than doing it on windows.
我很感激我收到的回复。我最终做的是让球滚动(我在网络开发中断以追求其他事情)并使事情变得更容易使用的是我设置了一个 LAMP 服务器,它使安装过程变得非常简单和直接,从那以后,我在创建虚拟主机和使我的网站正常工作以及让一切都以应有的方式进行交互时完全没有问题。如果您还停留在我原来的位置,那么在 Windows 上设置和使用 WAMP 比在 linux 系统上设置要复杂得多。在 linux 系统上,您不会获得像 WAMP 这样的专用 gui 程序,但是您将在操作系统中运行所有内容来处理它,它基本上将您的计算机变成具有 php/sql 支持的本地 Web 服务器,等等否则你 我想补充一下。我正在使用 kali linux,它对我来说很好。如果您只想深入研究 php 而不必克服 Windows 虚拟主机上的巨大障碍,我强烈建议您进行研究并在 linux 系统上进行设置。如果您有额外的硬盘驱动器,请将 linux 放在上面。如果没有,请在您的驱动器上设置双引导配置,以便您拥有 windows 和 linux。它帮助我学习了如何让后端的事物以我想要的方式相互引用,同时在我进行的过程中也能更好地理解它。您需要安装的只是 apache、mysql 和 php,在设置完所有内容后,它应该可以在您的本地机器上正常工作。开始学习 linux 似乎很可怕,
回答by Faizan
I believe this is the best and easiest solution:
我相信这是最好和最简单的解决方案:
Open index.php in www folder and set
在 www 文件夹中打开 index.php 并设置
change line 30:$suppress_localhost = true;
更改第 30 行:$suppress_localhost = true;
to $suppress_localhost = false;
到 $suppress_localhost = false;
This will ensure the project is prefixed with your local host IP/name
这将确保项目以您的本地主机 IP/名称为前缀
回答by Saravanan
Just change the value in wamp/www/index.php line no 338.
只需更改 wamp/www/index.php 第 338 行中的值即可。
Change this :
改变这一点:
From
从
$projectContents .= '<li><a href="'.($suppress_localhost ? 'http://' : '').$file.'">'.$file.'</a></li>';
to
到
$projectContents .= '<li><a href="'.($suppress_localhost ? 'http://localhost/' : '').$file.'">'.$file.'</a></li>';
回答by manitaz
Run the wamp server, Start apachee and enter the url as
运行wamp服务器,启动apachee并输入url为
http://localhost/websites/index.php
回答by RiggsFolly
There is a document on the WAMPServer forum HERE is the linkthat documents an amendment you can make to revert the Project links back to Pre 2.5 mechanisms
WAMPServer 论坛上有一个文档,这里有一个链接,其中记录了您可以进行的修改以将项目链接恢复到 Pre 2.5 机制
Look for the section entitled Revert WAMPServer 2.5 "Your Projects" links to pre 2.5 mechanism
查找标题为 Revert WAMPServer 2.5 "Your Projects" links to pre 2.5 mechanism
Here is the amendment :-
这是修正案:-
Revert WAMPServer 2.5 "Your Projects" links to pre 2.5 mechanism
将 WAMPServer 2.5“您的项目”链接恢复到 2.5 之前的机制
It would appear that some WAMPServer users cannot cope with creating Virtual Hosts for each of their sites/projects.
一些 WAMPServer 用户似乎无法为他们的每个站点/项目创建虚拟主机。
This is code that will be in the next version of WAMPServer so if you want your "Your Projects" menu to provide links in the form 'localhost/folder_name' rather than 'folder_name' so you dont have to create a simple Virtual Host definition, here is how it should be done.
这是 WAMPServer 下一版本中的代码,因此如果您希望“您的项目”菜单以“localhost/folder_name”而不是“folder_name”的形式提供链接,因此您不必创建简单的虚拟主机定义,这是应该如何完成的。
I would enphasise, this is not the recommended mechanism. The only GOOD solution is to use the Virtual Host mechanism
我要强调,这不是推荐的机制。唯一好的解决方案是使用虚拟主机机制
However, making these changes will not harm WampServer and you can always set suppressLocalhost = "yes" to keep the WAMPServer2.5 mechanism.
但是,进行这些更改不会损害 WampServer,您始终可以设置 suppressLocalhost = "yes" 以保留 WAMPServer2.5 机制。
- Edit wamp/wampmanager.conf
- 编辑 wamp/wampmanager.conf
In the section [main] add this line :
在 [main] 部分添加这一行:
suppressLocalhost = "no"
Save the file
保存文件
If this is set to "no" Your Project links will be in the form localhost/folder_name
i.e. the pre WAMPServer 2.5 way.
If this is set to "yes" Your Project links will be in the form folder_name
and require a Virtual Hosts definitions to work.
如果设置为“否”,您的项目链接将采用localhost/folder_name
WAMPServer 2.5 之前的格式。如果将其设置为“是”,您的项目链接将采用这种形式,folder_name
并且需要虚拟主机定义才能工作。
- Edit \wamp\www\index.php
- 编辑 \wamp\www\index.php
Locate this line
找到这一行
$suppress_localhost = true;
and comment it out like so:
并像这样注释掉:
//$suppress_localhost = true;
Find this line
$wampserverVersion = str_replace('"','',$result1); ajouter/add
找到这一行
$wampserverVersion = str_replace('"','',$result 1); ajouter/add
and after that line add this code
在该行之后添加此代码
//[modif oto] - On récupère la valeur de suppressLocalhost
preg_match('|suppressLocalhost = "(.*)"|',$wampConfFileContents,$result);
if($result[1] != "yes" )
$suppress_localhost = false;
else
$suppress_localhost = true;
Save this file
保存这个文件
- Edit /wamp/scripts/config.inc.php
- 编辑/wamp/scripts/config.inc.php
Find this line
找到这一行
$c_editor = $wampConf['editor']; ajouter/add :
and after that line add
在该行之后添加
//[modif oto] Ajout variable suppressLocalhost
if($wampConf['suppressLocalhost'] != "yes" )
$c_suppressLocalhost = false;
else
$c_suppressLocalhost = true;
Save the file
保存文件
- Edit /wamp/scripts/refresh.php
- 编辑/wamp/scripts/refresh.php
Find this line
找到这一行
{
$myreplacesubmenuProjects .= 'Type: item; Caption: "'.$projectContents[$i].'"; Action: run; FileName: "'.$c_navigator.'"; Parameters: "['.$projectContents][$i].'/"; Glyph: 5
and REPLACE it with
并将其替换为
{ //[modif oto] Support de suppressLocalhost dans wampmanager.conf
$myreplacesubmenuProjects .= 'Type: item; Caption: "'.$projectContents[$i].'"; Action: run; FileName: "'.$c_navigator.'"; Parameters: "'.($c_suppressLocalhost ? "["]; : 'http://localhost/').$projectContents[$i].'/"; Glyph: 5
Save this file.
保存此文件。
The changes are now complete.
更改现已完成。
Now restart WAMPServer
现在重启 WAMPServer