MAMP: reloading pages is very slow

2019-01-21 13:26发布

On a basic installation of MAMP, I'm building an application with CodeIgniter locally (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.

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.

I read on http://forum.mamp.info/viewtopic.php?f=6&t=14081 that 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.

What could I do about it?

4条回答
Viruses.
2楼-- · 2019-01-21 14:05

To solve the problem with .local domains on OSX, do the following (assuming your site is called mysite.local):

  1. Open your /etc/hosts file in a text editor
  2. Add the following entry on its own line ::1 mysite.local
  3. Save the file

This should resolve your issue.

查看更多
可以哭但决不认输i
3楼-- · 2019-01-21 14:08

If on OS X Yosemite. The edit to the localhost file will not fix it. You will need to do the following.

sudo launchctl unload -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.

查看更多
霸刀☆藐视天下
4楼-- · 2019-01-21 14:11

In my case the hosts file had thousands of lines of

127.0.0.1 mymachinename.local

entries

查看更多
闹够了就滚
5楼-- · 2019-01-21 14:24

The '.local' domains conflict with Bonjour, which treats anything with a '.local' TLD as a Bonjour server.

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.

The solution is to, as Jon said, put a ::1 address in/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.

The alternative is to put a different TLD - .dev or something like that.

查看更多
登录 后发表回答