How to make your WAMP run lightning fast again.
These steps to speed up your Apache, PHP, and MySQL installation on Windows will work for any WAMP installation, including WAMP Server and XAMPP. But some of the directory and file paths used here are specific to WampDeveloper (just substitute in the paths of your environment).
Windows
Windows Hosts file
Edit the Windows Hosts file and comment out the localhost to IPv6 loopback (::1) resolve line.
Edit file -
C:\Windows\System32\drivers\etc\hosts
Comment out the line by adding a ‘#’ in front:
# ::1 localhost
If localhost gets resolved to ::1, the request will still need to get routed back to 127.0.0.1, causing unnessasary delays.
The Windows Hosts file is usually set read-only, and requires Administrative permissions to edit. And some security applications can maintain an edit lock on this file.
IPv6
Always make sure to disable IPv6 on your system.
Problems with Windows and IPv6 have been known to add an additional half a second on the initial load-time of each request.
http://www.techunboxed.com/2012/08/how-to-disable-ipv6-in-windows-8.html
Firewall and Anti-Virus software
Some Firewall software (such as ZoneAlarm) and anti-virus software have been known to significantly slow down Apache and MySQL.
Try disabling them to see if it makes a difference.
If it does, open their settings, and add the httpd.exe and mysqld.exe paths to the list of excluded programs that should have full access to the system.
C:\WampDeveloper\Versions\Apache\apache-2.2.25.0-r1-win32-vc9-standard\bin\httpd.exe C:\WampDeveloper\Versions\Mysql\mysql-5.5.34.0-r1-win32-vcX-standard\bin\mysqld.exe
*You’ll need to do this for each version of Apache and MySQL that you use.
Also exclude the MySQL Database directory for any checks.
C:\WampDeveloper\Database
And possibly WAMP’s Temporary directory from any checks.
C:\WampDeveloper\Temp
Clear Your WAMP Log Files
Apache maintains website access and error logs that can grow in size very quickly. PHP also has similar logs (if enabled via configuration).
C:\WampDeveloper\Logs C:\WampDeveloper\Temp
Once Apache log files grow in size to above several 100MB, performance issues can arise.
Also the Temp folder holds lots of session and temporary data files that don’t get properly cleaned up, which causes it’s own issues.
You can clear out the Log and Temp files like this -
Make sure Apache and MySQL are not running.
Open the command-line and set the working directory to C:\WampDeveloper\Logs\.
C: cd \WampDeveloper\Logs
The command-prompt should now be: “C:\WampDeveloper\Logs>”.
Delete all the log files.
del /S *log.txt
Change to the Temp directory.
cd \WampDeveloper\Temp
The command-prompt should now be: “C:\WampDeveloper\Temp>”.
Delete all the log files.
del /S *
Since this is a pure wildcard filename delete (*), it will ask you if you want to delete all the files each time it finds a new sub-directory… As it prompts you, press the ‘y’ or ‘Y’ key, then press the ‘Enter’ key; or add in the /Q switch (del /S /Q *) to tell it not to prompt you at all.
The above will delete all the log files and all the temp files, within all the sub-directories. Make sure you do this carefully (that you are in the right directory) or you could delete all the files on your computer!
If you do this manually, make sure to never delete the directories and sub-directories, just the files in them.
Apache
BufferedLogs
Turn Log Buffering on. This will cause Apache to cache logs for multiple requests instead of writing them out individually to the log file – and improve disk I/O on a heavily accessed web server.
Edit file -
C:\WampDeveloper\Config\Apache\extra\wampd-custom.conf
BufferedLogs On
OS
Make sure these Directives are not turned Off (they are On by default) as they use the OS’s abilities to speed up memory access and file reading.
EnableMMAP On EnableSendfile On
http://httpd.apache.org/docs/2.2/mod/core.html#enablemmap
Make sure that this Directive is not present in the configuration as it disables a faster way of accepting network connections on Windows -
Win32DisableAcceptEx
http://httpd.apache.org/docs/2.2/mod/mpm_winnt.html#win32disableacceptex
MySQL
127.0.0.1 over localhost
Always use ’127.0.0.1′ instead of ‘localhost’, host-name, or a domain-name to make a connection to MySQL. Not doing so can cause delay issues due to Host file problems, improper routing tables, routing between IPv4 and IPv6, domain resolves, and timeouts.
99.9% of the time MySQL runs on the same system the PHP scripts are connecting from, and is bound to (listening-on) 127.0.0.1… All PHP scripts should be making the connection to MySQL directly via IP 127.0.0.1.
Make sure your scripts’ (and webapps’) configuration files do so, and that the MySQL account they use has its Host: field set to 127.0.0.1.
C:\WampDeveloper\Websites\www.example.com\webroot\wordpress\wp-config.php
/** MySQL hostname */
define('DB_HOST', '127.0.0.1');
If a PHP script attempted to connected to MySQL via a host-name or a real registered domain-name, that request could potentialy need to get resolved via DNS to an IP address, and that IP address would need to get routed back to the local system.
Also, if MySQL (and phpMyAdmin) will never be accessed from outside, you can disable MySQL’s DNS resolves and Host cache…
Edit my.ini, section [mysqld]:
skip-name-resolve skip-host-cache
MyISAM over InnoDB
If your database access pattern is mostly read-only (less than 15% writes – typical for most webapps like WordPress), try using MyISAM tables. But if it’s write heavy, consider
using InnoDB tables.
Database Buffer Size
Edit my.ini:
Try updating the buffer sizes to 1/4 or 1/2 of your RAM -
For MyISAM tables (caches indexes only, not the data)
key_buffer_size = 256M
For InnoDB tables (caches both indexes and data)
innodb_buffer_pool_size = 512M innodb_log_file_size = 128M
innodb_log_file_size should be 1/4 of the innodb_buffer_pool_size value.
Changing the value of innodb_log_file_size will either cause MySQL to fail to start, or for the InnoDB Engine to not load. You’ll need to delete (or move out just in case) file(s) C:\WampDeveloper\Database\ib_logfile0 and ib_logfile1 (if it exists). This is a bit unclean, but if everything was flushed and shut down properly, should not be problematic.
The other settings I would not mess with. They hardly ever give anything more than marginal returns, or none at all.
Even the above mentioned settings will have diminishing results with increased values on the average system.
You’re mostly looking to update the existing settings (and not introduce new ones) to set the buffer-sizes of InnoDB and MyISAM to hold all indexes and data in memory as a percentage of your available RAM, and the log sizes as a percentage of the buffer sizes, and leaving everything else alone. As other settings are marginal, introduce complexity, are way too specific (and override good default and autos), or are just not good for the health of the Database.
innodb_flush_log_at_trx_commit
The only other MySQL setting that can produce good performance gains – changes the way the above buffer is written out to the above log file, and how the whole thing is flushed to disk.
innodb_flush_log_at_trx_commit = 2
http://dev.mysql.com/doc/refman/5.5/en/innodb-parameters.html#sysvar_innodb_flush_log_at_trx_commit
The default value of 1 is required for full ACID compliance. With this value, the log buffer is written out to the log file at each transaction commit and the flush to disk operation is performed on the log file. With a value of 0, any mysqld process crash can erase the last second of transactions. The log buffer is written out to the log file once per second and the flush to disk operation is performed on the log file, but nothing is done at a transaction commit. With a value of 2, only an operating system crash or a power outage can erase the last second of transactions. The log buffer is written out to the file at each commit, but the flush to disk operation is not performed on it. However, the flushing on the log file takes place once per second also when the value is 2. Note that the once-per-second flushing is not 100% guaranteed to happen every second, due to process scheduling issues.
PHP
data.timezone
Make sure php.ini has date.timezone set to a value. Otherwise PHP will attempt to figure out which data-time zone to use on every call to a date related function.
realpath_cache_size
Update php.ini’s realpath_cache_size to a much larger value from the default 16K.
realpath_cache_size = 1M
For this to work, open_basedir cannot be set, and safe_mode cannot be On. See – https://bugs.php.net/bug.php?id=52312
Webapps
Updated the webapp’s MySQL user account (via \phpmyadmin) to change the “Host:” field from “localhost” to “127.0.0.1″.
Then update the webapp’s config file to reflect the change.
For example, edit Magento’s configuration file -
…\domain.name\app\etc\local.xml
Update line -
<host><![CDATA[localhost]]></host>
To -
<host><![CDATA[127.0.0.1]]></host>
WordPress
Typical -
Reset the internal rewrite-rules in wp-options table by clearing the value via \phpmyadmin.
Ultimate -
Refresh the entire wordpress database by Exporting it into an XML file via the Import/Export plugin. Then re-install wordpress (delete the WP database and access the WP website), and re-import the XML file via that same plugin.
Drupal
Clear (truncate) the session table and watchdog table via \phpmyadmin.
Clear the Cache under Drupal > Configuration > Development > Performance.