php WAMP 运行非常缓慢
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10750964/
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
WAMP is running very slow
提问by Terish Das
I am using WAMP(localhost) on Windows 7.
我在 Windows 7 上使用WAMP(本地主机)。
When I am running my localhostit takes more than 1 minute to load the page. There are no queries or database connectivity. If it's just an HTML page, it also takes the same time, and if the Internet is connected it works normally. If Internet is connected it works perfectly. When the Internet is not available it takes more than 1 minutes to load a simple page.
当我运行我的本地主机时,加载页面需要 1 多分钟。没有查询或数据库连接。如果只是一个HTML页面,也需要同样的时间,如果能上网就可以正常工作。 如果 Internet 已连接,它可以完美运行。当 Internet 不可用时,加载一个简单的页面需要 1 分钟以上的时间。
How can I fix this?
我怎样才能解决这个问题?
回答by Iulian Dita
The solution that worked for me was to disable the cgi_module. Use one of these methods:
对我有用的解决方案是禁用cgi_module。使用以下方法之一:
(Method 1)Left 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 Marko Aleksi?
Set mysql_connect('127.0.0.1'... instead of mysql_connect('localhost'....
设置 mysql_connect('127.0.0.1'... 而不是 mysql_connect('localhost'....
回答by tvanc
I tried a lot of the answers on here without much success. It was PHP itself where the bottleneck was occurring. I disabled Xdebug and my page-load time went from ~1200 ms to ~275 ms. That was where the biggest single gain occurred, by far.
我在这里尝试了很多答案,但都没有成功。瓶颈发生在 PHP 本身。我禁用了 Xdebug,我的页面加载时间从 ~1200 ms 到 ~275 ms。这是迄今为止最大的单一收益发生的地方。
回答by Booni
Instead of using the hostname “localhost”, use an IP address in your MySQL connection string.
不要使用主机名“localhost”,而是在 MySQL 连接字符串中使用 IP 地址。
Typically, your WAMP installation is found in C:\wamp.
Edit this file with Notepad:
通常,您的 WAMP 安装位于C:\wamp. 用记事本编辑这个文件:
C:\wamp\www\wp-config.php
Replace
代替
define("DB_HOST", "localhost");
with
和
define("DB_HOST", "127.0.0.1");
Restart the WAMP services.
重新启动 WAMP 服务。
You can check out more details on this website.
您可以在此网站上查看更多详细信息。
回答by Nicolas Janel
Accessing my local content on 127.0.0.1instead of localhostworked for me (so probably a DNS resolve issue is hidden somewhere):
访问我的本地内容127.0.0.1而不是localhost为我工作(所以可能 DNS 解析问题隐藏在某处):
http://127.0.0.1/mysiteis fasthttp://localhost/mysiteis slow
http://127.0.0.1/mysite很快http://localhost/mysite是慢的
回答by Fluffy
Changing the PHP SMTP server in file php.inifrom localhostto 127.0.0.1, on line 1084 in my vanilla copy, did the trick.
将文件中的 PHP SMTP 服务器php.ini从更改localhost为127.0.0.1,在我的原版副本中的第 1084 行,成功了。
回答by SystemicPlural
My problem was of a smaller scale. An empty PHP page went from almost instant rendering to about 1 second.
我的问题规模较小。一个空的 PHP 页面从几乎即时渲染到大约 1 秒。
It turned out that my Xdebug settings were causing the problem. I had xdebug.remote_enable=onset in the php.inifile, and this was causing the delay. Before I was starting, the debug session was using an idekey, so I only got the delay when starting a debug session. Commenting the line out solved the problem.
结果是我的 Xdebug 设置导致了这个问题。我已经xdebug.remote_enable=on在php.ini文件中设置,这导致了延迟。在我开始之前,调试会话正在使用一个idekey,所以我只在开始调试会话时得到了延迟。注释掉该行解决了问题。
回答by Ricky Sharma
Uncommenting this line in the hosts fileworked for me:
取消注释主机文件中的这一行对我有用:
# 'localhost' name resolution is handled within DNS itself.
127.0.0.1 localhost
# ::1 localhost
Uncommenting 127.0.01 localhost. And after that it's super fast.
取消注释127.0.01 localhost。在那之后它是超级快的。
回答by Daven
I'm running Windows 8, and WAMP was very slow. I did all suggested before. With a difference; WAMP had httpd.confby default:
我正在运行 Windows 8,WAMP 运行速度非常慢。我之前建议的都做了。有区别;httpd.conf默认情况下,WAMP 具有:
AcceptFilter http none
AcceptFilter https none
So I did the contrary thinking: Maybe this is not needed any more. It seems to work fine:
所以我做了相反的想法:也许不再需要这个了。它似乎工作正常:
#AcceptFilter http none
#AcceptFilter https none
Maybe is not a problem in all Windows versions. In httpd you read:
也许在所有 Windows 版本中都不是问题。在 httpd 中你读到:
# AcceptFilter: On Windows, none uses accept() rather than AcceptEx() and
# will not recycle sockets between connections. This is useful for network
# adapters with broken driver support, as well as some virtual network
# providers such as vpn drivers, or spam, virus or spyware filters.
#AcceptFilter http none
#AcceptFilter https none
回答by Hamed Azimi
Here is a list of changes I made to make WAMP faster in my Windows 10 Pro 64 bit:
以下是我为在 Windows 10 Pro 64 位中提高 WAMP 速度所做的更改列表:
- Edited hostsfile and added:
127.0.0.1 localhost - Edited hostsfile and added:
127.0.0.1 myVhosts(note: I added all other entries in the same line as the first one. I don't create multiple lines to point 127.0.0.1 to different places. So I only have one 127.0.0.1 and then next to it, any vhosts or anything else that I want to point to it) - Edited my.iniand added:
bind-address="127.0.0.1"(below [wampmysqld64]) - Disabled cgi_modulefrom Apache** → Apache Modules→ cgi_module(uncheck it)
- Disabled XDEBUG Extensionfrom php.ini
- As I have Anti-Virus and Firewall, added httpd.exeand mysqld.exefiles (as well as PHP CLI and CGI binaries, and PHP's DLL files) to the exceptions.
- Turned on EnableMMAPand EnableSendfilein httpd.conf
- Set realpath_cache_sizeto 4096kin php.ini
- In the end, edited the configuration file of projects and replaced the localhostwith 127.0.0.1as well.
- 编辑主机文件并添加:
127.0.0.1 localhost - 编辑主机文件,并补充说:
127.0.0.1 myVhosts(注:我添加了所有其他条目在同一行的第一个我不创建多行指向127.0.0.1到不同的地方所以我只有一个127.0.0.1,然后下一个。到它,任何虚拟主机或其他任何我想指向它的东西) - 编辑my.ini并添加:(
bind-address="127.0.0.1"在[wampmysqld64]下方) - 从 Apache禁用cgi_module** → Apache 模块→ cgi_module(取消选中它)
- 从php.ini禁用XDEBUG 扩展
- 由于我有防病毒和防火墙,因此将httpd.exe和mysqld.exe文件(以及 PHP CLI 和 CGI 二进制文件以及 PHP 的 DLL 文件)添加到例外中。
- 在httpd.conf 中开启EnableMMAP和EnableSendfile
- 在php.ini中将realpath_cache_size设置为4096k
- 最后,编辑项目的配置文件,并取代了本地主机与127.0.0.1为好。
I also recommend checking this article: WAMP is Running Very Slow. They covered a lot of changes that may help you as well.
我还建议您查看这篇文章:WAMP 运行速度非常慢。他们涵盖了许多可能对您也有帮助的更改。

