Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP on Windows with XAMPP running 100 times too slow

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?

like image 644
CaptureWiz Avatar asked Apr 20 '16 20:04

CaptureWiz


People also ask

Does xampp Slow PC?

Doing a development on windows using XAMPP with default install on windows can give you a nightmares due to its dead slow speed of processing. I too had same issue of slow processing speed on XAMPP. I too did a lot of googling for solution to increase the speed.

Why does localhost take so long to respond?

The 'taking too long to respond' error indicates that there is a communication problem between the target server and the client (your web browser). It means that the targeted server is taking a long time to send a response to the client. The error is usually sent if the client cannot get a response within 30 seconds.

Is xampp good for PHP?

Xampp is the most popular PHP development environment for Windows, OS X, and Linux platforms.


4 Answers

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

like image 142
CaptureWiz Avatar answered Oct 08 '22 16:10

CaptureWiz


I solve my problem with xdebug idekey setting (xdebug.idekey="xdebug1"), and chrome extension xdebug helper (https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc)

*Dont forget to disable remote_autostart (xdebug.remote_autostart=0)

Only activating debug (xdebug) by request, using idekey setting, so if debug not needed php processing can be faster/normal, tonggle by button with chrome extension

I'm using xampp 1.8.3 on windows 10 64bit, i use custom idekey, xdebug.idekey="xdebug1", same with xdebug helper setting

[XDebug]
zend_extension = "E:\xampp183\php\ext\php_xdebug.dll"
xdebug.profiler_append = 0
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "E:\xampp183\tmp"
xdebug.profiler_output_name = "cachegrind.out.%t-%s"
xdebug.remote_enable = 1
xdebug.remote_autostart=0
xdebug.idekey="xdebug1"
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "127.0.0.1"
xdebug.trace_output_dir = "E:\xampp183\tmp"
xdebug.remote_log="E:\xampp183\tmp\xdebug\xdebug.log"

setting1

enter image description here

enter image description here

Now breakpoint/debug activated only if session is requsted via xdebug helper

like image 30
Nuha Dzikri Avatar answered Oct 08 '22 17:10

Nuha Dzikri


I excluded my website folder and my xampp folder in Windows Defender and things were solved here.

like image 22
Carsten Wartmann Avatar answered Oct 08 '22 16:10

Carsten Wartmann


I Had the same problem with xampp, and the problem was WINDOWS DEFENDER, if you disable the windows defender protection, xampp is faster (normal speed), Also you can search the xampp folder as exlusion in windows defender. these is the solution.

like image 28
ALEX MAURICIO HENAO HERNANDEZ Avatar answered Oct 08 '22 16:10

ALEX MAURICIO HENAO HERNANDEZ