English 中文(简体)
XAMPP on Win7 too slow
原标题:

I m running XAMPP 1.7.1 on Windows 7 Ultimate. Everything (Apache & MySQL) is working fine except for speed.

When I open http://localhost/, I must wait probably 1-3 seconds for view a webpage. 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..."
  • CPU is still idle (no increased activity while loading)
  • on localhost is no demanding PHP scripts, problems are when there is simple phpinfo() even if there is long heavy scripts.
  • disabling MySQL server don t affect speed
  • my PC: AMD Turion 64 X2; 1,6 GHz dual-core, 2 GB RAM, 100 GB HDD

I ve made a little simple benchmark PHP script to test HDD/CSS speeds:

<?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
  • CPU speed: 0.816 / 0.767 / 0.795

A webhosting results:

  • Read/write: 7.768 / 7.69 / 7.371
  • CPU speed: 0.232 / 0.234 / 0.234

One of my server s results (as idle computer nearly as my PC, but a little bit faster):

  • Read/write: 0.088 / 0.168 / 0.185
  • CPU speed: 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. Do you have some experience with XAMPP speed on Windows 7 (or Vista) ?

Thanks.

问题回答

If XAMP is slow under windows 7, the firewall settings make no difference.
The Security Essentials anti-virus makes no difference.

To solve this problem, the two things that make a big difference are:

1) in windowssystem32driversetchosts add the following lines:

127.0.0.1 127.0.0.1

127.0.0.1 localhost

2) If you re using PHP, in the XAMP php.ini file uncomment the eaccelerator line:

zend_extension = "C:xamppphpextphp_eaccelerator_ts.dll"

After these two changes, restart Apache and it will be way faster.

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:WINDOWSsystem32driversetchosts, if I remember correctly) file ?

If yes, comment that line by adding a # at the beginning.


This way, the only line that s about localhost should be

127.0.0.1    localhost

which is an IPv4 address ; and the one you commented being an IPv6 -- which is quite not useful for what you are trying to do.


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 (i.e. waiting a long time before doing anything on the server).

Comment the lines in PHP.ini with XDEBUG:

;[XDebug]

    ;zend_extension = "C:xamppphpextphp_xdebug.dll"
    ;xdebug.profiler_append = 0
    ;xdebug.profiler_enable = 1
    ;xdebug.profiler_enable_trigger = 0
    ;xdebug.profiler_output_dir = "C:xampp	mp"
    ;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	mp"


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

Best regards Barto

I had similar issue with 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. Big PHP scripts with a lot of chained require_once()s tooked more than 1,5 seconds. 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())).

I am using bitdeffender and here is the solution for it:

  1. Simple solution - just switch bitdefender to game mode when working with xampp
  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/). Then go to Antivirus -> Exclusions and add exclusion for the directory where your php files reside.

Don t forget to restart apache after above steps.

Optionally you can install eaccelerator to speed the things even more.

As I side note: I found WAMP less mature as a project than XAMPP.

Side note 2: The best solution is to use your old PC as linux server and everything will work like a charm :-)

After reading several answers - non of them helped (I even removed my antivirus).

What helped me dramatically is disabling xdebug. Now everything became very fast.

Two things can cause this issue.Anitivirus software and the settings in hostfile

1) in windowssystem32driversetchosts add the following lines:

127.0.0.1 127.0.0.1

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). To test this, you can also disable your anti virus temporarily but long term fix is to exclude the folder and subfolders

My BUG - XAMPP VERY SLOW

My Xampp slow down and eventual stop was caused by warnings messages filling the php log - read on

1 - Localhost/127.0.0.1 - no help

2 - Virus software interference - no help

3 - Port interference changing to 8080 - no help

4 - Wamp - same thing - no help

eventually things failed altogether with 500 errors.

C:xamppphplogsphp_error_log was almost a MB (957K)

too big for notepadd++ (my first clue I was on to something) and notepad took several minutes to render.

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."

nenamed log

restarted apache and mysql

Life is good.

How about giving Wamp Server a try?

The installation file is a lot smaller (16mb) compare to XAMPP (44mb).

http://wampserver.com/

In C:WINDOWSsystem32driversetchosts I had these lines commented

# 127.0.0.1 localhost
# ::1       localhost

and around 100 more lines of other rules. The solution is to erase all those rules or to uncomment 127.0.0.1 localhost and put in on top.

Connecting to the DB using 127.0.0.1 instead of "localhost" worked for me.

But i searched for another solution and came up with this:

In your my.ini file, uncomment the following line:

    # 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.

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"

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 commented these 10000+ entries with a copyright date of 2008, making them useless anyway.

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. 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.

enter image description here

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”
  2. You will find CustomLog "logs/access.log" common
  3. replace with CustomLog "|bin/rotatelogs.exe logs/access_%y-%m-%d.log 86400" common
  4. You can do same thing with logs/error.log files.
  5. for more information of rotate program please follow https://httpd.apache.org/docs/2.4/programs/rotatelogs.html

i also agree with disble Xdebug will help too.

This is what I did and it made XAMPP ways faster:

  1. Assigned a new and unused loopback address to my site in the hosts file (C:WindowsSystem32driversetchosts). In other words I avoided using 127.0.0.1 used for other sites:

    127.0.0.2 example.com

  2. In the Apache httpd.conf file added:

    Listen 127.0.0.2: 80

  3. As I have several sites, I have subfolders under htdocs for each site. In this example the foldername is example.com, and that is where my site sits. So added a VirtualHost, again in my httpd.conf file, like so:

    <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.

After that, visiting example.com in the browser loads really quick.

I have same problem....

What I did is I uninstalled xampp which was on C: drive .

Installed it onto another drive (E:)...

and dont know but its working fine and fast....

I use Avast antivirus and solved the problem with a simple click. Right-click the Avast icon and select Silent/gaming mode. 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.

i found good advice here:
[http://www.devside.net/wamp-server/wamp-is-running-very-slow

the instructions were as follows: Edit file – C:WindowsSystem32driversetchosts

Comment out the line by adding a ‘#’ in front:

::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 (e.g., typically anywhere from 1 second to 30 seconds).

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





相关问题
Why running a service as Local System is bad on windows?

I am trying to find out the difference between difference service account types. I tumbled upon this question. The answer was because it has powerful access to local resources, and Network Service ...

Programmatically detect Windows cluster configuration?

Does anyone know how to programatically detect that a Windows server is part of a cluster? Further, is it possible to detect that the server is the active or passive node? [Edit] And detect it from ...

get file icon for Outlook appointment (.msg)

I ve read Get File Icon used by Shell and the other similar posts - and already use SHFileInfo to get the associated icon for any given extension, and that works great. However, Outlook uses ".msg" ...

Identifying idle state on a windows machine

I know about the GetLastInputInfo method but that would only give me the duration since last user input - keyboard or mouse. If a user input was last received 10 minutes ago, that wouldn t mean the ...

Terminating a thread gracefully not using TerminateThread()

My application creates a thread and that runs in the background all the time. I can only terminate the thread manually, not from within the thread callback function. At the moment I am using ...

热门标签