PHP on Windows with XAMPP running 100 times too slow

CaptureWiz picture CaptureWiz · Apr 20, 2016 · Viewed 35.1k times · Source

PHP runs so slowly on my Windows desktop that phpMyAdmin takes minutes to open a database. Here’s a comparison of the time to run a simple PHP test program:

  • Windows 8.1 machine running XAMPP: 3597 ms
  • iPage shared hosting: 65 ms
  • A2Hosting shared hosting: 26 ms

Here’s the test program…

<?php
$rStartTime = microtime(true);
$countTo = 100000;
$a = 0;
//$countTo = $countTo * 100;
for ($x = 0; $x <= $countTo; $x++) {
    $a = sqrt(pow($x, 2));
}
$rMs = floor((microtime(true) - $rStartTime) * 1000);
echo 'timer done, countTo=' . $a . ' ms=' . $rMs;

The test program is run without debugging, by entering "http://localhost/timer.php" into Firefox.

The local machine is normally blazing fast. It’s running…

  • Windows 8.1
  • XAMPP 1.8.3 (control panel v3.2.1)
  • Apache 2.4.4 (latest is 2.4.20)
  • PHP 5.5.3
  • Antimalware = Windows Defender
  • IDE = PHPStorm 10.0.2

What's making PHP run so slowly?

Answer

CaptureWiz picture CaptureWiz · Apr 20, 2016

I found the problem was Xdebug in xampp\php\php.ini. Here're the results of trying many solutions found around the web:

Run XAMPP as adminisrator and restart server: 3617 ms

In xampp/apache/conf/httpd.conf, replace localhost with 127.0.0.1 and restart server: 3639 ms

In Windows/System32/drivers/etc/hosts, add “127.0.0.1 127.0.0.1” & “127.0.0.1 localhost” and restart Windows: 3960 ms

In Windows/System32/drivers/etc/hosts, un-comment “127.0.0.1 localhost” and restart Windows: 3659 ms

In php.ini, uncomment zend_extension = "C:\xampp\php\ext\php_eaccelerator_ts.dll" and restart server: 3643 ms

In php.ini, set xdebug.remote_enable=0: 3598 ms

In php.ini, set remote_host="localhost": 3593 ms

In php.ini, set xdebug.profiler_enable=0: 249 ms

In php.ini, comment out all Xdebug statements: 27 ms - Success!

The sad part is, I make mistakes and need Xdebug :-(