PHP on Windows with XAMPP running 100 times too slow

PHP on Windows with XAMPP running 100 times too slow

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

PHP on Windows with XAMPP running 100 times too slow

Running a simple loop in PHP should be instantaneous, but on a local Windows desktop using XAMPP, it can take nearly four seconds. That is an order of magnitude slower than shared hosting environments like iPage or A2Hosting, which respond in milliseconds. When phpMyAdmin takes minutes to load on your own machine, the bottleneck isn't your internet connection or database storage; it's almost certainly the interaction between Windows Defender and the Apache/PHP stack.

The provided test program runs a loop of 100,000 iterations performing basic arithmetic operations. On a Linux server or a clean Windows setup, this executes in under a millisecond. However, when executed via http://localhost/timer.php on XAMPP 1.8.3 with Apache 2.4.4 and PHP 5.5.3, the execution time balloons to 3597 ms.

The primary suspect is Windows Defender's real-time scanning. By default, modern versions of Windows Defender scan every file as it is written to disk. In a web hosting environment, files are static; Apache serves them directly. On a local development machine running XAMPP, the scenario is different. When you save timer.php or when Apache attempts to serve the file, Windows Defender hooks into the process, reads the binary content, scans it for malware signatures, and then passes it along.

This scanning introduces significant latency during the request-response cycle. Every time a user (or in this case, your browser) requests a page, the OS has to pause the web server thread to perform an I/O operation that involves the antivirus engine. While the CPU overhead of calculating sqrt(pow($x, 2)) is negligible on modern hardware, the I/O wait for disk access and context switching becomes the dominant factor in the total execution time.

To resolve this, you must configure Windows Defender to exclude specific folders from real-time scanning. This is not a security risk if done correctly; it simply prevents the OS from re-scanning files that are part of your active development environment.

You can add these exclusions via the Windows Security settings:

  1. Open Windows Security and navigate to Virus & threat protection.
  2. Click Manage settings under "Virus & threat protection settings".
  3. Select Exclusions and then click Add or remove exclusions.

Add the following paths to your exclusion list:

  • C:\xampp (or wherever you installed XAMPP)
  • Your project source directories if they exist elsewhere

Once these exclusions are active, Apache will serve PHP files without waiting for Defender to analyze them. You should also ensure that your web server is configured to handle requests efficiently, though the exclusion step alone usually drops execution times from 3500ms back to single-digit milliseconds, matching the performance of shared hosting.

It is worth noting that this issue is specific to the local development environment. Shared hosts like A2Hosting (26 ms) and iPage (65 ms) do not run full real-time antivirus scans on every file serve request in the same way Windows does locally. They rely on periodic signature updates rather than per-file blocking I/O during the request lifecycle.

If you are migrating a project from this slow local setup to production, ensure your production server uses a lightweight web server configuration and an antivirus solution that supports exclusions for web root directories. Using LaravelCompany's resources can help streamline this migration by providing best practices for environment-specific configurations that avoid these common Windows pitfalls.

The lesson here is clear: the fastest CPU in the world cannot compensate for an I/O bottleneck introduced by aggressive real-time file scanning. By tuning your local antivirus settings, you restore the expected performance of your development tools without compromising system security against actual threats.

Our network