php MAMP:重新加载页面非常慢
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8452614/
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
MAMP: reloading pages is very slow
提问by Gchtr
On a basic installation of MAMP, I'm building an application with CodeIgniter locally (MacBook Pro, Core2Duo 2,26 GhZ, 4GB RAM).
在MAMP的基本安装中,我正在本地使用 CodeIgniter 构建应用程序(MacBook Pro、Core2Duo 2,26 GhZ、4GB RAM)。
My problem is, that when I reload a page, it does load very slow, even slower than when I put on a web server.
我的问题是,当我重新加载页面时,它的加载速度非常慢,甚至比我在 Web 服务器上加载时还要慢。
It's strange that it only loads slow when I reload the page, not when I click on a link in the application itself.
奇怪的是,它只在我重新加载页面时加载缓慢,而不是当我单击应用程序本身中的链接时。
The application uses a MySQL database, but even when I reload a page that doesn't make MySQL queries, it's so slow, that it takes about 10 seconds to load a page.
该应用程序使用 MySQL 数据库,但即使我重新加载一个不进行 MySQL 查询的页面,它也很慢,加载一个页面大约需要 10 秒。
I read on http://forum.mamp.info/viewtopic.php?f=6&t=14081that I could try to change the server name from .local to .dev. But I don't know how to do that and didn't find anything when I googled it.
我在http://forum.mamp.info/viewtopic.php?f=6&t=14081上读到我可以尝试将服务器名称从 .local 更改为 .dev。但我不知道该怎么做,当我用谷歌搜索时没有找到任何东西。
What could I do about it?
我能怎么办?
回答by Dan Blows
The '.local' domains conflict with Bonjour, which treats anything with a '.local' TLD as a Bonjour server.
“.local”域与 Bonjour 冲突,Bonjour 将任何带有“.local”顶级域名的东西都视为 Bonjour 服务器。
I found the answer here: http://www.bram.us/2011/12/12/mamp-pro-slow-name-resolving-with-local-vhosts-in-lion-fix/, and that post refers to https://discussions.apple.com/message/15834652#15834652.
我在这里找到了答案:http: //www.bram.us/2011/12/12/mamp-pro-slow-name-resolving-with-local-vhosts-in-lion-fix/,该帖子指的是https://discussions.apple.com/message/15834652#15834652。
The solution is to, as Jon said, put a ::1
address in/etc/hosts.
正如 Jon 所说,解决方案是::1
在 /etc/hosts 中放置一个地址。
::1 localhost example.local anotherexample.local
Unfortunately, MAMP Pro will delete the entry when it restarts so put a tab (not spaces) between the IP and each of the hosts.
不幸的是,MAMP Pro 将在重新启动时删除该条目,因此在 IP 和每个主机之间放置一个制表符(而不是空格)。
The alternative is to put a different TLD - .dev
or something like that.
另一种方法是放置一个不同的 TLD -.dev
或类似的东西。
回答by Jon
To solve the problem with .local domains on OSX, do the following (assuming your site is called mysite.local):
要解决 OSX 上 .local 域的问题,请执行以下操作(假设您的站点名为 mysite.local):
- Open your
/etc/hosts
file in a text editor - Add the following entry on its own line
::1 mysite.local
- Save the file
/etc/hosts
在文本编辑器中打开您的文件- 在其自己的行上添加以下条目
::1 mysite.local
- 保存文件
This should resolve your issue.
这应该可以解决您的问题。
回答by Saint48198
If on OS X Yosemite. The edit to the localhost file will not fix it. You will need to do the following.
如果在 OS X Yosemite 上。对 localhost 文件的编辑不会修复它。您将需要执行以下操作。
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.discoveryd.plist
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.discoveryd.plist
sudo launchctl 卸载 -w /System/Library/LaunchDaemons/com.apple.discoveryd.plist
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.discoveryd.plist
The fix is via https://coderwall.com/p/ylchfq. Update is in the comments.
修复是通过https://coderwall.com/p/ylchfq 进行的。更新在评论中。