php Mamp localhost解析非常缓慢

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18537887/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 17:45:42  来源:igfitidea点击:

Mamp localhost resolving very slowly

phpmysqlwordpressmamphosts

提问by user2733720

When I make local changes to my PHP / WordPress website, the localhost does not seem to update for 20-30 minutes.

当我对 PHP / WordPress 网站进行本地更改时,本地主机似乎在 20-30 分钟内没有更新。

I'm on Mac OSX 10.8.4 and using MAMP Pro. I have two sites that I have created separate host entries for, let's call them mysite1.devand mysite2.dev.

我在 Mac OSX 10.8.4 上使用 MAMP Pro。我有两个网站,我已经创建了单独的主机条目,让我们称他们mysite1.devmysite2.dev

Here is my MAMP Server configuration:

这是我的 MAMP 服务器配置:

Apache: 80
MySQL: 3306
SSL: 443

I saw this article ( How can I eliminate slow resolving/loading of localhost/virtualhost (a 2-3 second lag) on Mac OS X Lion?) on the Bonjour conflicts and edited my /private/etc/hostsfile with the suggestions in this article:

我在 Bonjour 冲突中看到了这篇文章(如何在 Mac OS X Lion 上消除本地主机/虚拟主机的缓慢解析/加载(2-3 秒延迟)?)并/private/etc/hosts使用本文中的建议编辑了我的文件:

  1. I changed the host names from mysite1.localhostto mysite.devbecause it sounds like the conflict is with .localnames - DID NOT WORK

  2. I updated the Hosts file to have separate ::1addresses - DID NOT WORK:

    ::1 <tab> mysite1.dev
    ::1 <tab> mysite2.dev
    
  3. I tried putting all of my host entries onto one line - also didn't work:

    127.0.0.1 localhost mysite1.dev mysite2.dev
    ::1 localhost
    fe80::1%lo0 localhost
    
  1. 我将主机名从 更改为mysite1.localhostmysite.dev因为听起来冲突与.local名称有关 - 不起作用

  2. 我更新了 Hosts 文件以具有单独的::1地址 - 不起作用:

    ::1 <tab> mysite1.dev
    ::1 <tab> mysite2.dev
    
  3. 我尝试将所有主机条目放在一行上 - 也不起作用:

    127.0.0.1 localhost mysite1.dev mysite2.dev
    ::1 localhost
    fe80::1%lo0 localhost
    

It seems like MAMP Pro overwrites the hosts file any time I restart the server.

I would be SUPER grateful for any help you can offer.

每次我重新启动服务器时,MAMP Pro 似乎都会覆盖主机文件。

如果您能提供任何帮助,我将不胜感激。

回答by shamila

Change MAMP cache to OPcache. It worked for me enter image description here

将 MAMP 缓存更改为 OPcache。它对我有用在此处输入图片说明

回答by WaZzo

I had the same problem and found the solution on this post: MAMP time between seeing live changes

我遇到了同样的问题,并在这篇文章中找到了解决方案: MAMP time between see live changes

The instructions, which I followed:

我遵循的说明:

The solution is uncommenting lines in the php.inifile, which can be found in

解决方案是取消注释php.ini文件中的行,可以在

/{MAMP Directory}/bin/php/php5.5.3/conf/php.ini

Comment out Opcache:

注释掉 Opcache:

[OPcache]
;zend_extension="/Applications/MAMP/bin/php/php5.5.3/lib/php/extensions/no-debug-non-zts-20121212/opcache.so"
;  opcache.memory_consumption=128
;  opcache.interned_strings_buffer=8
;  opcache.max_accelerated_files=4000
;  opcache.revalidate_freq=60
;  opcache.fast_shutdown=1
;  opcache.enable_cli=1

Documentation ( yes it started in 5.5 ):

文档(是的,它从 5.5 开始):

http://www.php.net/manual/en/intro.opcache.php

http://www.php.net/manual/en/intro.opcache.php

回答by Paul Bakker

For me, changing back to MAMPS standard port settings did the trick.

对我来说,改回 MAMPS 标准端口设置可以解决问题。

回答by Alexander Holdt

I had similar problems running php 5.5.3. After I changed back to 5.4.19it worked.

我在运行 php 5.5.3 时遇到了类似的问题。在我改回5.4.19它之后,它起作用了。

You can change the version in the MAMP GUI. You might have to rename your 5.5.3folder to 5.5.Xfor 5.4.19to show up in the GUI. The phpfolders are placed at: Applications/MAMP/bin/php

您可以在MAMP GUI. 您可能需要将5.5.3文件夹重命名为5.5.Xfor5.4.19才能显示在 GUI 中。将php文件夹放置在:Applications/MAMP/bin/php

回答by photocurio

MAMP's default ports are non-standard. When I switched to standard ports (80 for Apache & 443 for SSL), it sped up dramatically.

MAMP 的默认端口是非标准的。当我切换到标准端口(Apache 为 80,SSL 为 443)时,速度显着加快。

I'm not sure if this is what Paul Bakker did, or if he switched the other way.

我不确定这是 Paul Bakker 所做的,还是他换了另一种方式。

I'm using MAMP Pro 4.2, PHP 7.1.6, Apache, OS X 10.11.6.

我使用的是 MAMP Pro 4.2、PHP 7.1.6、Apache、OS X 10.11.6。

回答by M_iserte

It was really hard, but I found a solution that it works in my environment:

这真的很难,但我找到了一个适用于我的环境的解决方案:

  • MAMP 4.2.1
  • PHP 5.6.31
  • MAMP 4.2.1
  • PHP 5.6.31

SETTINGS left menu > Ports settings > Run servers as: > Change it to "Unix Users" option.

设置左侧菜单 > 端口设置 > 运行服务器: > 将其更改为“Unix 用户”选项。

enter image description here

在此处输入图片说明

回答by hemanto

I'm not sure about Mamp, however, I use php -S 0.0.0.0:4444to spin up a local server. Its response got very slow after moving to Mojave.

我不确定 Mamp,但是,我php -S 0.0.0.0:4444用来启动本地服务器。搬到莫哈韦沙漠后,它的反应变得非常缓慢。

I was able to fix it by updating /etc/hostsfile with

我能够通过更新/etc/hosts文件来修复它

::1             localhost YouMacName.local
127.0.0.1       localhost YouMacName.local

You can get YourMacName.local by running in terminal:

您可以通过在终端中运行来获取 YourMacName.local:

$ hostname

回答by Ian

Changing from PHP 7 to 5 fixed mine.

从 PHP 7 更改为 5 修复了我的问题。