简体   繁体   English

Win7上的XAMPP太慢了

[英]XAMPP on Win7 too slow

I'm running XAMPP 1.7.1 on Windows 7 Ultimate. 我在Windows 7旗舰版上运行XAMPP 1.7.1。 Everything (Apache & MySQL) is working fine except for speed. 除了速度之外,一切(Apache和MySQL)都运行良好。

When I open http://localhost/ , I must wait probably 1-3 seconds for view a webpage. 当我打开http:// localhost /时 ,我必须等待1-3秒才能查看网页。 In my opinion, it should be at most some hundreds miliseconds. 在我看来,它应该最多几百毫秒。

Basic facts: 基本事实:

  • while waiting to load a localhost webpage, status bar says "Waiting for localhost..." 在等待加载localhost网页时,状态栏显示“正在等待localhost ...”
  • CPU is still idle (no increased activity while loading) CPU仍处于空闲状态(加载时没有增加活动)
  • on localhost is no demanding PHP scripts, problems are when there is simple phpinfo() even if there is long heavy scripts. 在localhost上没有要求的PHP脚本,问题是当有简单的phpinfo()时,即使有很长的重脚本。
  • disabling MySQL server don't affect speed 禁用MySQL服务器不会影响速度
  • my PC: AMD Turion 64 X2; 我的电脑:AMD Turion 64 X2; 1,6 GHz dual-core, 2 GB RAM, 100 GB HDD 1,6 GHz双核,2 GB RAM,100 GB HDD

I've made a little simple benchmark PHP script to test HDD/CSS speeds: 我做了一个简单的基准PHP脚本来测试HDD / CSS速度:

<?php

function getmicrotime() { 
    list($usec, $sec) = explode(" ", microtime());
    return ((float)$usec + (float)$sec);
}

function testReadWrite() {
 $timeStart = getmicrotime();
 $filename = "test.txt";

 file_put_contents( $filename, '' ); // prepare empty file

 for ( $i = 0; $i < 1000; $i++ ) {
  $a = file_get_contents( $filename );
  file_put_contents( $filename, $a . '.' );
 }

 return round( getmicrotime() - $timeStart, 3 );
} 


function testCpuSpeed() {
 $timeStart = getmicrotime();

 $var = '';
 for ( $i = 0; $i < 100000; $i++ ) {
  $var = sha1( md5( $i * $i * $i * $i * $i * $i * $i * $i * $i * $i ) );
 }

 return round( getmicrotime() - $timeStart, 3 );
}

echo "Read/write #1: " . testReadWrite() . "<BR>";
echo "Read/write #2: " . testReadWrite() . "<BR>";
echo "Read/write #3: " . testReadWrite() . "<BR>";
echo "CPU speed #1: " . testCpuSpeed() . "<BR>";
echo "CPU speed #2: " . testCpuSpeed() . "<BR>";
echo "CPU speed #3: " . testCpuSpeed() . "<BR>";

?>

My PC results: 我的电脑结果:

  • Read/write: 5.134 / 3.431 / 3.494 读/写:5.134 / 3.431 / 3.494
  • CPU speed: 0.816 / 0.767 / 0.795 CPU速度:0.816 / 0.767 / 0.795

A webhosting results: 网站托管结果:

  • Read/write: 7.768 / 7.69 / 7.371 读/写:7.768 / 7.69 / 7.371
  • CPU speed: 0.232 / 0.234 / 0.234 CPU速度:0.232 / 0.234 / 0.234

One of my server's results (as idle computer nearly as my PC, but a little bit faster): 我服务器的一个结果(就像我的PC一样闲置计算机,但速度稍快一点):

  • Read/write: 0.088 / 0.168 / 0.185 读/写:0.088 / 0.168 / 0.185
  • CPU speed: 0.191 / 0.189 / 0.189 CPU速度:0.191 / 0.189 / 0.189

So I don't think that it is because of my PC speed, but I'm sure that there's some another problem. 所以我不认为这是因为我的PC速度,但我确信还有一些问题。 Do you have some experience with XAMPP speed on Windows 7 (or Vista) ? 您是否对Windows 7(或Vista)上的XAMPP速度有一定的经验?

Thanks. 谢谢。

If XAMP is slow under windows 7, the firewall settings make no difference. 如果在Windows 7下XAMP很慢,则防火墙设置没有区别。
The Security Essentials anti-virus makes no difference. Security Essentials防病毒没有任何区别。

To solve this problem, the two things that make a big difference are: 要解决这个问题,两个有很大不同的地方是:

1) in windows\\system32\\drivers\\etc\\hosts add the following lines: 1)在windows \\ system32 \\ drivers \\ etc \\ hosts中添加以下行:

127.0.0.1 127.0.0.1 127.0.0.1 127.0.0.1

127.0.0.1 localhost 127.0.0.1 localhost

2) If you're using PHP, in the XAMP php.ini file uncomment the eaccelerator line: 2)如果您正在使用PHP,则在XAMP php.ini文件中取消注释eaccelerator行:

zend_extension = "C:\\xampp\\php\\ext\\php_eaccelerator_ts.dll" zend_extension =“C:\\ xampp \\ php \\ ext \\ php_eaccelerator_ts.dll”

After these two changes, restart Apache and it will be way faster. 在这两个更改之后,重新启动Apache,它会更快。

Comment the lines in PHP.ini with XDEBUG: 使用XDEBUG注释PHP.ini中的行:

;[XDebug]

    ;zend_extension = "C:\xampp\php\ext\php_xdebug.dll"
    ;xdebug.profiler_append = 0
    ;xdebug.profiler_enable = 1
    ;xdebug.profiler_enable_trigger = 0
    ;xdebug.profiler_output_dir = "C:\xampp\tmp"
    ;xdebug.profiler_output_name = "cachegrind.out.%t-%s"
    ;xdebug.remote_enable = 0
    ;xdebug.remote_handler = "dbgp"
    ;debug.remote_host = "127.0.0.1"
    ;xdebug.trace_output_dir = "C:\xampp\tmp"

I disabled Bitdefeender -> no result
    I added lines to hosts -> no result
    I disabled xdebug - x2-x3 faster

Best regards Barto 最好的问候巴托

Not sure this might be the cause of your problems, but this might be an idea : do you have a line that looks like this : 不确定这可能是你的问题的原因,但这可能是一个想法:你有一个看起来像这样的行:

::1 localhost

in your hosts (it should be somewhere like C:\\WINDOWS\\system32\\drivers\\etc\\hosts , if I remember correctly) file ? 在您的主机(它应该在某个地方,如C:\\WINDOWS\\system32\\drivers\\etc\\hosts ,如果我没记错的话)文件?

If yes, comment that line by adding a # at the beginning. 如果是,请在开头添加#注释该行。


This way, the only line that's about localhost should be 这样,关于localhost的唯一一行应该是

127.0.0.1    localhost

which is an IPv4 address ; 这是一个IPv4地址; and the one you commented being an IPv6 -- which is quite not useful for what you are trying to do. 而你评论的那个是IPv6 - 这对你要做的事情没有用。


As I said, not sure your problem is related to this, but I've seen this sugestion help a couple of times for problems quite similar to your (ie waiting a long time before doing anything on the server) . 正如我所说,不确定你的问题是否与此有关,但我已经看到这种消息帮助了几次与你的问题非常相似的问题(即在服务器上做任何事情之前等了很长时间)

I had similar issue with Win 7 + XAMPP. 我和Win 7 + XAMPP有类似的问题。 The problem was caused by the my antivirus software. 问题是由我的防病毒软件引起的。 When it was enabled even simplest PHP page was taking more than half a sec to open. 当启用它时,即使是最简单的PHP页面也需要超过半秒的时间才能打开。 Big PHP scripts with a lot of chained require_once()s tooked more than 1,5 seconds. 带有大量链接require_once()的大PHP脚本花了超过1.5秒。 With antivirus disabled everything was lightening fast (less than 100 miliseconds per simple pages, and about 500 miliseconds for really heavy stuff (100+ chained require_once())). 在禁用防病毒功能的情况下,一切都很快(每个简单页面少于100毫秒,对于非常重的东西(100 +链接require_once())大约500毫秒)。

I am using bitdeffender and here is the solution for it: 我正在使用bitdeffender,这是它的解决方案:

  1. Simple solution - just switch bitdefender to game mode when working with xampp 简单的解决方案 - 在使用xampp时只需将bitdefender切换到game mode
  2. "Advanced" solution - go to Antivirus -> Shield -> Advanced Settings -> Exclusions Tab and there add exclusion for httpd.exe (located in your xampp installation/apache/bin/). “高级”解决方案 - 转到Antivirus -> Shield -> Advanced Settings -> Exclusions Tab然后为httpd.exe添加排除(位于您的xampp安装/ apache / bin /中)。 Then go to Antivirus -> Exclusions and add exclusion for the directory where your php files reside. 然后转到Antivirus -> Exclusions并为php文件所在的目录添加排除项。

Don't forget to restart apache after above steps. 不要忘记在执行上述步骤后重启apache。

Optionally you can install eaccelerator to speed the things even more. 您可以选择安装eaccelerator来加快速度。

As I side note: I found WAMP less mature as a project than XAMPP. 我个人注意到:我发现WAMP作为一个项目比XAMPP更不成熟。

Side note 2: The best solution is to use your old PC as linux server and everything will work like a charm :-) 旁注2:最好的解决方案是使用旧PC作为Linux服务器,一切都会像魅力一样:-)

After reading several answers - non of them helped (I even removed my antivirus). 阅读了几个答案后 - 他们没有帮助(我甚至删除了我的防病毒软件)。

What helped me dramatically is disabling xdebug . 帮助我显着的是禁用xdebug Now everything became very fast. 现在一切都变得非常快。

Two things can cause this issue.Anitivirus software and the settings in hostfile 有两件事可能导致这个问题.Anitivirus软件和hostfile中的设置

1) in windows\\system32\\drivers\\etc\\hosts add the following lines: 1)在windows \\ system32 \\ drivers \\ etc \\ hosts中添加以下行:

127.0.0.1 127.0.0.1 127.0.0.1 127.0.0.1

127.0.0.1 localhost 127.0.0.1 localhost

2) In your antivirus, exclude the document_root folder that contains your files (eg c:/www or c:/xampp/htdoc etc). 2)在防病毒软件中,排除包含文件的document_root文件夹(例如c:/ www或c:/ xampp / htdoc等)。 To test this, you can also disable your anti virus temporarily but long term fix is to exclude the folder and subfolders 要对此进行测试,您还可以暂时禁用防病毒,但长期解决方法是排除文件夹和子文件夹

In C:\\WINDOWS\\system32\\drivers\\etc\\hosts I had these lines commented C:\\WINDOWS\\system32\\drivers\\etc\\hosts我对这些行进行了评论

# 127.0.0.1 localhost
# ::1       localhost

and around 100 more lines of other rules. 还有大约100多条其他规则。 The solution is to erase all those rules or to uncomment 127.0.0.1 localhost and put in on top. 解决方案是删除所有这些规则或取消注释127.0.0.1 localhost并置于顶部。

How about giving Wamp Server a try? 如何试试Wamp Server?

The installation file is a lot smaller (16mb) compare to XAMPP (44mb). 与XAMPP(44mb)相比,安装文件要小得多(16mb)。

http://wampserver.com/ http://wampserver.com/

My BUG - XAMPP VERY SLOW 我的BUG - XAMPP非常慢

My Xampp slow down and eventual stop was caused by warnings messages filling the php log - read on 我的Xampp减速并最终停止是由填充php日志的警告消息引起的 - 继续阅读

1 - Localhost/127.0.0.1 - no help 1 - Localhost / 127.0.0.1 - 没有帮助

2 - Virus software interference - no help 2 - 病毒软件干扰 - 没有帮助

3 - Port interference changing to 8080 - no help 3 - 端口干扰变为8080 - 没有帮助

4 - Wamp - same thing - no help 4 - Wamp - 同样的事情 - 没有帮助

eventually things failed altogether with 500 errors. 最终事情总共失败了500个错误。

C:\\xampp\\php\\logs\\php_error_log was almost a MB (957K) C:\\ xampp \\ php \\ logs \\ php_error_log几乎是MB(957K)

too big for notepadd++ (my first clue I was on to something) and notepad took several minutes to render. 对于notepadd ++来说太大了(我的第一个线索是我做的事情)并且记事本花了几分钟来渲染。

Thousands of messages of the "Strict' & 'Warning' type 成千上万的“严格”和“警告”类型的消息

FIX 固定

changed the php.ini display_errors=On to =Off "There are several other error on/off switches in there, but this one did it for me." 更改了php.ini display_errors = On to = Off“还有其他几个错误的开/关开关,但这个为我做了。”

nenamed log nenamed log

restarted apache and mysql 重启apache和mysql

Life is good. 生活很好。

Connecting to the DB using 127.0.0.1 instead of "localhost" worked for me. 使用127.0.0.1而不是“localhost”连接到数据库对我有用。

But i searched for another solution and came up with this: 但我搜索了另一个解决方案并想出了这个:

In your my.ini file, uncomment the following line: my.ini文件中,取消注释以下行:

    # Change here for bind listening
    # bind-address="127.0.0.1" 
    # bind-address = ::1          # for ipv6

You'll end up having: 你最终会得到:

    # Change here for bind listening
      bind-address="127.0.0.1" 
    # bind-address = ::1          # for ipv6

Restart your mysql server and pages should load very fast without the 2-3 second delay. 重启你的mysql服务器,页面加载速度非常快,没有2-3秒的延迟。

Also, with this solution you don't need to modify your connection in your DB connect code, you can continue using "localhost" instead of "127.0.0.1" 此外,使用此解决方案,您无需在数据库连接代码中修改连接,您可以继续使用“localhost”而不是“127.0.0.1”

At the risk of stating the obvious -- check the size of your hosts file. 冒着明显的风险 - 检查主机文件的大小。 My hosts file had ballooned to 450K due to Spybot adding exceptions for every malware site that ever existed even though those sites were mostly no longer active. 由于Spybot为每个存在的恶意软件网站添加了例外,即使这些网站大部分不再处于活动状态,我的主机文件已经膨胀到450K。 Spybot commented these 10000+ entries with a copyright date of 2008, making them useless anyway. Spybot对这10000多个条目进行了评论,其版权日期为2008年,无论如何都无用。

I don't know if other spyware protection software does this, but the hosts file should be small enough so that XAMPP doesn't have to churn through the exception URLs every time it displays a page. 我不知道其他间谍软件保护软件是否会这样做,但是hosts文件应该足够小,以便XAMPP不必每次显示页面时都通过异常URL。 BTW if you have any cracked software installed, which I don't condone of course, be careful not to delete the hosts exceptions that block online validation checking sites. 顺便说一句,如果您安装了任何破解软件,我当然不会宽恕,请注意不要删除阻止在线验证检查站点的主机异常。

i had same issue year back ago and finally find out what makes problem here. 一年前我有同样的问题,最后找出问题所在。 what if your log (access,errors) files are going to such a huge that it will a take time to open even with notepad? 如果您的日志(访问,错误)文件变得如此庞大以至于即使使用记事本也需要花费时间,该怎么办?

yes, you heard right xampp will create those files. 是的,您听说xampp会创建这些文件。

在此输入图像描述

Now If we have problem then there is solution too. 现在如果我们有问题,那么也有解决方案。 we can rotate log files for every day. 我们可以每天轮换日志文件。 here is steps 这是步骤

  1. Edit your httpd.conf in this path “Xampp/apache/conf/httpd.conf” 在此路径“Xampp / apache / conf / httpd.conf”中编辑httpd.conf
  2. You will find CustomLog "logs/access.log" common 您会发现CustomLog "logs/access.log" common
  3. replace with CustomLog "|bin/rotatelogs.exe logs/access_%y-%m-%d.log 86400" common 替换为CustomLog "|bin/rotatelogs.exe logs/access_%y-%m-%d.log 86400" common
  4. You can do same thing with logs/error.log files. 您可以使用logs / error.log文件执行相同的操作。
  5. for more information of rotate program please follow https://httpd.apache.org/docs/2.4/programs/rotatelogs.html 有关旋转程序的更多信息,请访问https://httpd.apache.org/docs/2.4/programs/rotatelogs.html

i also agree with disble Xdebug will help too. 我同意disble Xdebug也会有所帮助。

I have same problem.... 我有同样的问题....

What I did is I uninstalled xampp which was on C: drive . 我做的是我卸载xampp,它在C: drive

Installed it onto another drive (E:) ... 安装到另一个驱动器(E:) ...

and dont know but its working fine and fast.... 并且不知道,但它的工作正常和快速....

I use Avast antivirus and solved the problem with a simple click. 我使用Avast防病毒软件并通过简单的点击解决了这个问题。 Right-click the Avast icon and select Silent/gaming mode. 右键单击Avast图标,然后选择静音/游戏模式。 That's all. 就这样。

i had this problem, it was not related to anti-virus or firewall. 我有这个问题,它与防病毒或防火墙无关。 was easily fixed by ensuring local host was looking for 127.0.0.1. 很容易通过确保本地主机正在寻找127.0.0.1来修复。

i found good advice here: 我在这里找到了很好的建议
[ http://www.devside.net/wamp-server/wamp-is-running-very-slow [ http://www.devside.net/wamp-server/wamp-is-running-very-slow

the instructions were as follows: Edit file – C:\\Windows\\System32\\drivers\\etc\\hosts 说明如下:编辑文件 - C:\\ Windows \\ System32 \\ drivers \\ etc \\ hosts

Comment out the line by adding a '#' in front: 通过在前面添加“#”来注释掉该行:

::1 localhost :: 1 localhost

If “localhost” gets resolved to IP address “::1″, the request (when not able to find an IPv6 listening socket) will get routed back to IP address 127.0.0.1 (via timeout, fall-back, or some other mechanism), causing unnecessary delays for connections (eg, typically anywhere from 1 second to 30 seconds). 如果“localhost”被解析为IP地址“:: 1”,则该请求(当无法找到IPv6侦听套接字时)将被路由回IP地址127.0.0.1(通过超时,回退或其他一些机制) ),导致连接的不必要的延迟(例如,通常在1秒到30秒的任何时间)。

Make sure that “localhost” is correctly mapped to the IPv4 loopback address “127.0.0.1” (…that this line is not commented out): 127.0.0.1 localhost 确保“localhost”正确映射到IPv4环回地址“127.0.0.1”(...此行未注释掉):127.0.0.1 localhost

This is what I did and it made XAMPP ways faster: 这就是我所做的,它使XAMPP更快:

  1. Assigned a new and unused loopback address to my site in the hosts file (C:\\Windows\\System32\\drivers\\etc\\hosts). 在hosts文件(C:\\ Windows \\ System32 \\ drivers \\ etc \\ hosts)中为我的站点分配了一个新的和未使用的环回地址。 In other words I avoided using 127.0.0.1 used for other sites: 换句话说,我避免使用127.0.0.1用于其他网站:

    127.0.0.2 example.com

  2. In the Apache httpd.conf file added: 在Apache httpd.conf文件中添加:

    Listen 127.0.0.2: 80

  3. As I have several sites, I have subfolders under htdocs for each site. 由于我有几个站点,我在每个站点的htdocs下都有子文件夹。 In this example the foldername is example.com, and that is where my site sits. 在这个例子中,foldername是example.com,这就是我的网站所在的位置。 So added a VirtualHost, again in my httpd.conf file, like so: 所以在我的httpd.conf文件中添加了一个VirtualHost,如下所示:

    <VirtualHost 127.0.0.2:80> ServerAdmin myemail@hotmail.com DocumentRoot "C:/xampp/htdocs/example.com" ServerName example.com ErrorLog "c:/xampp/apache/logs/example.log" CustomLog "c:/xampp/apache/logs/example-access.log" common </VirtualHost>

  4. Restarted Apache. 重启Apache。

After that, visiting example.com in the browser loads really quick. 之后,在浏览器中访问example.com的速度非常快。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Laravel 4.2项目在xampp / win7上运行,但不在Ubuntu上运行 - Laravel 4.2 projects working on xampp/win7 but not on Ubuntu XAMPP 与 Wordpress 运行太慢 - XAMPP with Wordpress running too too slow 如何在 win7 x64 上使用带有 php (xampp) 的 oracle 客户端 11.2 - How to use oracle client 11.2 with php (xampp) on win7 x64 无法使用XAMPP 1.8.3在Win7 64位上安装PHP 5.5.6的memcache - Can not install memcache for PHP 5.5.6 on Win7 64-bit with XAMPP 1.8.3 修复在运行xampp php的win7中找到/ tmp和phpcs的Cygwin Emacs flycheck-mode错误 - Fix Cygwin Emacs flycheck-mode errors finding /tmp and phpcs in win7 running xampp php Codeigniter 3 + PHP 5.6 + Xampp + SQLServer 2008 + Win7 64x - Codeigniter 3 + php 5.6 + xampp + sqlserver 2008 + win7 64x EasyPHP win7服务器上的Kohana Web应用程序中的SQL查询极其缓慢 - SQL query extremely slow in Kohana web app on EasyPHP win7 server XAMPP 在 Windows 上运行的 PHP 速度太慢了 100 倍 - PHP on Windows with XAMPP running 100 times too slow mysqldump在win7沼泽中创建空文件 - mysqldump create empty file in win7 wamp 在WAMP(Win7)上安装ImageMagick:找不到类 - Installing ImageMagick on WAMP (Win7) : Class not found
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM