php WAMP/XAMPP 在本地主机上的响应非常慢

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

WAMP/XAMPP is responding very slow over localhost

phpapachexampplocalhostwamp

提问by FBwall

I don't know what the problem is. WAMP was very slow, so I reformatted my computer and installed WAMP. Still, accessing localhost is very, very slow, and sometimes it doesn't even load at all. I even removed it and replaced it with XAMPP, but I still got the same result. What might possibly be the problem? Here's my current hosts file:

我不知道是什么问题。WAMP 很慢,所以我重新格式化了我的电脑并安装了 WAMP。尽管如此,访问 localhost 还是非常非常慢,有时甚至根本无法加载。我什至删除了它并用 XAMPP 替换它,但我仍然得到相同的结果。可能是什么问题?这是我当前的主机文件:

127.0.0.1       localhost

127.0.0.1       localhost

It was perfectly working fine before, but I do not know what happened and why it has started acting strange lately, since even a reformat didn't fix it.

之前它运行良好,但我不知道发生了什么以及为什么它最近开始变得奇怪,因为即使重新格式化也无法解决它。

回答by bicycle

I had the same problem running on Windows 8 running on 64bit. Apache is really slow but when you press F5 many times it goes ok. In the end i after doing many things managed to solve it. Right now it works fast.

我在运行 64 位的 Windows 8 上运行时遇到了同样的问题。Apache 真的很慢,但是当您多次按 F5 时就可以了。最后,我做了很多事情后设法解决了它。现在它工作得很快。

Try the following tasks to increase the performance:

尝试以下任务以提高性能:

Change apache's listening port

更改apache的监听端口

Change listening port from 80 to 8080 to avoid conflicts with programs like Skype. Open your httpd.conf file and find the line that starts with Listen(it's around line 62). Change it like the following: Listen 127.0.0.1:8080

将侦听端口从 80 更改为 8080,以避免与 Skype 等程序冲突。打开您的 httpd.conf 文件并找到以 开头的行Listen(大约在第 62 行)。像下面这样改变它: Listen 127.0.0.1:8080

enter image description here

在此处输入图片说明

Change your powerplan

更改您的电源计划

Change your power plan from Balanced to High Performance. You can do this in Control Panel\All Control Panel Items\Power Options

将您的电源计划从平衡更改为高性能。你可以在Control Panel\All Control Panel Items\Power Options

enter image description here

在此处输入图片说明

Disable IPv6

禁用 IPv6

The credits of this particular task go to Jefwhere he pointed this out in his blog post. From the Windows 8 desktop, press the Windows Keyand the R keyat the same time

这个特殊任务的功劳归于 Jef,他在他的博客文章中指出了这一点。从Windows 8桌面,按下Windows KeyR key在同一时间

enter image description here

在此处输入图片说明

Type regedit in the Run dialog box and click OK

在“运行”对话框中键入 regedit,然后单击“确定”

enter image description here

在此处输入图片说明

Use Registry Editor to expand the registry tree and browse to:

使用注册表编辑器展开注册表树并浏览到:

\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TCPIP6\Parameters

enter image description here

在此处输入图片说明

Right click on Parameters, expand New, and select DWORD (32-bit)Value

右键单击Parameters,展开New并选择DWORD (32-bit)

enter image description here

在此处输入图片说明

Enter DisabledComponentsinto the Namefield

进入DisabledComponentsName现场

enter image description here

在此处输入图片说明

Double click on the new DisabledComponentsvalue, enter ffffffffinto the Value datadialog box, and click the OKbutton

双击新DisabledComponents值,输入ffffffffValue data对话框,然后单击OK按钮

enter image description here

在此处输入图片说明

Confirm the new registry value contains the required data.

确认新的注册表值包含所需的数据。

enter image description here

在此处输入图片说明

Change your etc/hosts

更改您的 etc/hosts

If you use virtual hosts don't add each virtual host on a new line. Instead list them like the following. 127.0.0.1 site-a site-b site-c

如果您使用虚拟主机,请不要在新行中添加每个虚拟主机。而是像下面那样列出它们。 127.0.0.1 site-a site-b site-c

I also added 127.0.0.1 127.0.0.1since I heard this somehow improves the lookup as well. (Can't confirm this but it can't hurt putting it there)

我还补充说,127.0.0.1 127.0.0.1因为我听说这也以某种方式改善了查找。(无法确认这一点,但把它放在那里不会有什么坏处)

enter image description here

在此处输入图片说明

Your hosts file is located at C:\Windows\System32\Drivers\etc

您的主机文件位于 C:\Windows\System32\Drivers\etc

Check how many apache processes are running

检查有多少 apache 进程正在运行

In my case I had two apache processes running. Be sure you only have one running. You can check this by pressing CTRL+ALT+DELand press Task Manager

就我而言,我有两个 apache 进程正在运行。确保你只有一个正在运行。您可以通过按CTRL+ALT+DEL和 按Task Manager

enter image description here

在此处输入图片说明

Turn off the Base Filtering Engine (BFE)

关闭基础过滤引擎 (BFE)

What I find to be working a bit as well was turning off the Base Filtering Engine. Since stopping or disabling the BFE service will significantly reduce the security of the system you should only do this when needed.

我发现还有一点作用是关闭基本过滤引擎。由于停止或禁用 BFE 服务会显着降低系统的安全性,因此您应该仅在需要时执行此操作。

Go to Control Panel => Administrative Tools => Services => Base Filtering Engine

转到控制面板 => 管理工具 => 服务 => 基本过滤引擎

enter image description here

在此处输入图片说明

Stop the Base Filtering Engine by clicking on Stop

通过单击停止停止基本过滤引擎

enter image description here

在此处输入图片说明

Increase Apache's process priority

增加Apache的进程优先级

To to your task manager and change Apache's process priority from Normal to High by right clicking -> Set priority -> Highenter image description here

到您的任务管理器并通过右键单击 -> 设置优先级 -> 高将 Apache 的进程优先级从普通更改为在此处输入图片说明

Keep Apache's process busy

让 Apache 的进程保持忙碌

This is a bit of an ugly method but it does certainly work. It keeps Apache busy and will process your own requests faster. Insert your local web-address in the iframe location and save it in a html file, run it and just leave it there until you're done.

这是一个有点丑陋的方法,但它确实有效。它使 Apache 保持忙碌并更快地处理您自己的请求。将您的本地网址插入 iframe 位置并将其保存在一个 html 文件中,运行它,然后将其留在那里直到完成。

<html>
    <head>

<script>
setTimeout(function(){
   window.location.reload(1);
}, 2000);

</script>

</head>
<body>
<iframe name="iframe" id="iframe" src="http://mywebsite:8080"></iframe> 


</body>
</html>

Downgrade to Windows 7 Pro

降级到 Windows 7 专业版

As a Windows 8 Pro user you are entitled to have downgrade rights to Windows 7. Read heremore about this. For me that was the only solution that really did the job properly.

作为 Windows 8 专业版用户,您有权获得 Windows 7 的降级权限。在此处阅读有关此内容的更多信息。对我来说,这是真正正确完成工作的唯一解决方案。

Good luck!

祝你好运!

回答by Honesta

This is caused by IPV6. Here is how you make MYSQL not use it. (so, without disabling IPV6)

这是由 IPV6 引起的。下面是如何让 MYSQL 不使用它。(因此,无需禁用 IPV6)

edit mysql file 'my.ini'

编辑 mysql 文件“my.ini”

under the [wampmysqld]add the following:

[wampmysqld] 下添加以下内容:

bind-address = ::

Save file and restart mysql service

保存文件并重启mysql服务

enjoy!

请享用!

回答by Stephan

have a look here :

看看这里:

http://forum.wampserver.com/read.php?2,91602,page=3

http://forum.wampserver.com/read.php?2,91602,page=3

Basically use 127.0.0.1instead of localhostwhen connecting to mysql through php on windows 8

基本上使用127.0.0.1而不是localhost在 Windows 8 上通过 php 连接到 mysql 时

if your finding phpmyadmin slow

如果你发现 phpmyadmin 很慢

in the config.inc.phpyou can change localhost to 127.0.0.1also

config.inc.php你可以更改本地主机来127.0.0.1

回答by Iulian Dita

The solution that worked for me was to disable the cgi_module. Use one of these methods:

对我有用的解决方案是禁用cgi_module。使用以下方法之一:

(Method 1)Right click on WAMP > Apache > Apache Modules > uncheck "cgi_module"

(方法1)右键单击WAMP > Apache > Apache Modules > 取消选中“cgi_module”

(Method 2)Edit httpd.confand disable the loading of the CGI module by commenting this line:

(方法2)编辑httpd.conf并通过注释此行禁用CGI模块的加载:

LoadModule cgi_module modules/mod_cgi.so

Commenting would be just adding a #in front, like this:

评论只是在前面添加一个#,如下所示:

#LoadModule cgi_module modules/mod_cgi.so

Restart the Apache service and you should be good to go.

重新启动 Apache 服务,您应该一切顺利。

回答by trogne

In my case, load time is 5 times faster when this is disabled in php.ini :

就我而言,在 php.ini 中禁用此功能时,加载时间快 5 倍:

;zend_extension = "\xampp\php\ext\php_xdebug-2.1.0-5.3-vc6.dll"

回答by user3476854

For me using xDebug, this line in php.ini was the performance killer:

对于使用 xDebug 的我来说,php.ini 中的这一行是性能杀手:

xdebug.remote_autostart=true

xdebug.remote_autostart=true

When I removed it the page was fast again.

当我删除它时,页面又很快了。

回答by Sujay sreedhar

if you are using mysql use 127.0.0.1instead of localhostin mysql_connectfunction it helped me

如果您使用 mysql use127.0.0.1而不是localhostmysql_connect函数中,它对我有帮助

回答by vcoppolecchia

I'm not yet able to comment under @Honesta answer, so I'll write here the way I manage to solve it.

我还不能在@Honesta 的回答下发表评论,所以我会在这里写我设法解决它的方式。

My environment (I don't know if this is relevant for the answer)

我的环境(我不知道这与答案是否相关)

  • XAMPP (version 5.6.3)
  • Windows 8.1 Pro (64 bit)
  • XAMPP(版本 5.6.3)
  • Windows 8.1 专业版(64 位)

How to

如何

I just opened my.inifile and uncommented the line where it says

我刚刚打开my.ini文件并取消注释它说的那一行

bind-address="127.0.0.1"

This file is located, for XAMPP users, in C:\xampp\mysql\bin\my.ini.

对于 XAMPP 用户,此文件位于C:\xampp\mysql\bin\my.ini.

Credits

学分

This articlehelped me to solve the problem, although I didn't needed everything in it because some setup in XAMPP were not requested.

这篇文章帮助我解决了这个问题,尽管我不需要其中的所有内容,因为 XAMPP 中的某些设置没有被要求。

回答by Mita Ka

I've just fixed such an issue on my laptop running windows 10. Suddenly wamp became super slow - a request to load a page was taking 2 minutes.

我刚刚在运行 Windows 10 的笔记本电脑上解决了这样一个问题。突然 wamp 变得非常慢 - 加载页面的请求需要 2 分钟。

After trying numerous things, what it turned out to fix the problem was disabling windows defender. All worked like a charm after that.

在尝试了很多事情之后,解决问题的方法是禁用 Windows Defender。在那之后,一切都像魅力一样。

p.s. I'd suggest you add your apache root dir to the exceptions list and not actually disable defender completely.

ps 我建议你将你的 apache 根目录添加到例外列表中,而不是完全禁用防御者。

回答by rightstuff

As most of the answers have pointed out, using the IP address 127.0.0.1 over "localhost" will sometimes help the slowness issue - but this isn't really a solution because it does not fix the underlining problem.

正如大多数答案所指出的那样,在“localhost”上使用 IP 地址 127.0.0.1 有时会帮助解决缓慢问题 - 但这并不是真正的解决方案,因为它不能解决下划线问题。

What makes this problem hard (and hit-and-miss), is it can be caused by about a dozen different things between the OS, the WAMP configuration, and your Browser.

是什么让这个问题变得困难(而且屡试不爽),是因为它可能是由操作系统、WAMP 配置和您的浏览器之间的十几种不同因素引起的。

  1. Remove ::1 localhostfrom your Windows hosts file, and make sure 127.0.0.1 localhostis present. You want your request to go directly to the listening IPv4 socket.

  2. Disable IPv6 on your system. You are most likely not using it, and it has been known to cause all kinds of issues.

  3. Exclude your Apache and MySQL binary paths, and the Database folder, from your firewall and anti-virus software. They willinterfere and slow things down.

  4. Reset your TCP/IP sub-system and reboot: netsh int ip reset c:\resetlog.txt

  5. Make sure your system is not using stale DNS servers: ipconfig /all

  6. Flush Windows DNS cache: ipconfig /flushdns

  7. Clear your Browser's Cache.

  1. ::1 localhost从您的 Windows 主机文件中删除,并确保127.0.0.1 localhost存在。您希望您的请求直接转到侦听 IPv4 套接字。

  2. 在您的系统上禁用 IPv6。您很可能没有使用它,并且众所周知它会导致各种问题

  3. 从防火墙和防病毒软件中排除 Apache 和 MySQL 二进制路径以及数据库文件夹。他们干扰并减慢速度。

  4. 重置 TCP/IP 子系统并重新启动: netsh int ip reset c:\resetlog.txt

  5. 确保您的系统没有使用陈旧的 DNS 服务器: ipconfig /all

  6. 刷新 Windows DNS 缓存: ipconfig /flushdns

  7. 清除浏览器的缓存。

A little more in-depth is this guide: WAMP is Running Very Slow

本指南更深入一点:WAMP 运行速度非常慢