Speed Up WordPress/PHP in Local Development (localhost)

If your Xampp websites are running slowly on your localhost installation (particularly for WordPress sites), following these steps can improve speed and performance. These steps are targeted at Xampp stacks On Windows.

Working locally on WordPress websites can be painful if they’re running slowly. You may find this in particular with WordPress installations that have WooCommerce, as this adds a lot of additional overhead.

1) Make Some Adjustments to the php.ini file

This is located at c:\xampp\php\php.ini

#memory_limit=128M #original
memory_limit=2048M
post_max_size=8M #original (allow upload of bigger files)
post_max_size=40M
#upload_max_filesize=2M
upload_max_filesize=40M

2) Set DB_HOST as “127.0.0.1”

Several experiments and reports suggest setting the WP_HOST setting in your wp-config.php file can improve performance. It certainly doesn’t hurt. Instead of “localhost”, trying setting this to “127.0.0.1”

Make Some Changes to my.ini (MySQL)

In Windows, Xampp, MySQL and WordPress can often run slow together. One contributor to this is the settings in my.ini – a MySQL configuration file.

Location of the file, typically: C:\xampp\mysql\bin\my.ini
Not to be confused with: C:\xampp\mysql\data\my.ini

It can be enhanced by editing some items:

#sql_mode=NO_ZERO_IN_DATE,NO_ZERO_DATE,NO_ENGINE_SUBSTITUTION #orig (allow more flexibility when importing dates to tables)
sql_mode=NO_ENGINE_SUBSTITUTION
#key_buffer=16M #orig
key_buffer=124M

#innodb_buffer_pool_size=16M #orig
innodb_buffer_pool_size=512M

#innodb_log_file_size=5M #orig
innodb_log_file_size=128M

#max_allowed_packet=1M #orig
max_allowed_packet = 128M

Common advice suggests setting the total innodb_log_file_size (that’s the size per file times the number of files) to about 25% of the innodb_buffer_pool_size

XDebug – It Slows Performance

Here are some techniques if you use xDebug. xDebug is invaluable for development and testing, but when you’re not using it, switching it off or adjusting settings can improve WordPress localhost performance dramatically. Commenting out xDebug from your php.ini file entirely can improve performance. See below for a brief suggestion, or visit XDebug and its Impact On Performance (Xampp) for a more thorough explanation. Note the ; (semi-colon) represents commented our lines in php.ini, don’t get tricked by adding # tags as comments (which are often used in other PHP setting files). The below configuration ensures that xDebug isn’t used at all.

[XDebug]
;off xdebug.mode=debug
;xdebug.start_with_request=yes ;heavier on xampp performance
;off xdebug.start_with_request=trigger ;to improve xampp performance
;off zend_extension = "C:\xampp\php\ext\php_xdebug.dll"

Turn Off Windows Defender for

There are reports of Windows defender slowing PHP/Xampp performance, you can set it so that Windows Defender stops operating for the Xampp folder:

0 0 votes
Rating
Subscribe
Notify of
guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Manmeet Singh
Manmeet Singh
3 months ago

Appreciated your work for this well written, very simple and straightforward guide, thanks!


1
0
Would love your thoughts, please comment.x
()
x