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
Mamp localhost resolving very slowly
提问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.dev
and mysite2.dev
.
我在 Mac OSX 10.8.4 上使用 MAMP Pro。我有两个网站,我已经创建了单独的主机条目,让我们称他们mysite1.dev
和mysite2.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/hosts
file with the suggestions in this article:
我在 Bonjour 冲突中看到了这篇文章(如何在 Mac OS X Lion 上消除本地主机/虚拟主机的缓慢解析/加载(2-3 秒延迟)?)并/private/etc/hosts
使用本文中的建议编辑了我的文件:
- I changed the host names from
mysite1.localhost
tomysite.dev
because it sounds like the conflict is with.local
names - DID NOT WORK I updated the Hosts file to have separate
::1
addresses - DID NOT WORK:::1 <tab> mysite1.dev ::1 <tab> mysite2.dev
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
- 我将主机名从 更改为
mysite1.localhost
,mysite.dev
因为听起来冲突与.local
名称有关 - 不起作用 我更新了 Hosts 文件以具有单独的
::1
地址 - 不起作用:::1 <tab> mysite1.dev ::1 <tab> mysite2.dev
我尝试将所有主机条目放在一行上 - 也不起作用:
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 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.ini
file, 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 开始):
回答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.19
it 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.3
folder to 5.5.X
for 5.4.19
to show up in the GUI. The php
folders are placed at: Applications/MAMP/bin/php
您可以在MAMP GUI
. 您可能需要将5.5.3
文件夹重命名为5.5.X
for5.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
回答by hemanto
I'm not sure about Mamp, however, I use php -S 0.0.0.0:4444
to 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/hosts
file 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 修复了我的问题。