Martin Ille
Martin Ille

Reputation: 7055

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:

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:

A webhosting results:

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

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.

Upvotes: 26

Views: 50852

Answers (16)

Goboca
Goboca

Reputation: 11

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:\Windows\System32\drivers\etc\hosts). 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 [email protected] 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.

Upvotes: 1

chudasamachirag
chudasamachirag

Reputation: 327

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.

Upvotes: 1

OurHighHopes
OurHighHopes

Reputation: 1

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:\Windows\System32\drivers\etc\hosts

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

Upvotes: 0

VanAlbert
VanAlbert

Reputation: 2469

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.

Upvotes: 1

ChelaTheGreat
ChelaTheGreat

Reputation: 75

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"

Upvotes: 1

Joe
Joe

Reputation: 137

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:\xampp\php\logs\php_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.

Upvotes: 2

lesm
lesm

Reputation: 23

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.

Upvotes: 0

Sanket Gupta
Sanket Gupta

Reputation: 573

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

1) in windows\system32\drivers\etc\hosts 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

Upvotes: 2

Barto
Barto

Reputation: 479

Comment the lines in PHP.ini with XDEBUG:

;[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

Upvotes: 15

JoeV
JoeV

Reputation: 441

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 windows\system32\drivers\etc\hosts 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:\xampp\php\ext\php_eaccelerator_ts.dll"

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

Upvotes: 44

bumbu
bumbu

Reputation: 1317

In C:\WINDOWS\system32\drivers\etc\hosts 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.

Upvotes: 1

Yada
Yada

Reputation: 31265

How about giving Wamp Server a try?

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

http://wampserver.com/

Upvotes: 1

Pratik
Pratik

Reputation: 1541

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

Upvotes: 0

Ognyan
Ognyan

Reputation: 13600

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 :-)

Upvotes: 11

Ronny Sherer
Ronny Sherer

Reputation: 8602

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.

Upvotes: 8

Pascal MARTIN
Pascal MARTIN

Reputation: 401182

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 ?

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

Upvotes: 15

Related Questions