Installation
- Disable and remove any other caching plugin you may be using — most plugins have uninstall procedures you can follow. Make sure wp-content/ has 777 permissions (e.g.: # chmod 777 /var/www/vhosts/domain.com/httpdocs/wp-content/) before proceeding.
- Unzip and upload the plugin to your plugins directory (wp-content/plugins/) when done wp-content/plugins/w3-total-cache/ should exist. If you have WordPress MU you will need to install this in wp-content/mu-plugins/w3-total-cache/.
- Locate and activate the plugin on the Plugins page. Set the permisions of wp-content back to 755 (e.g.: # chmod 755 /var/www/vhosts/domain.com/httpdocs/wp-content/) and click through to the General Settings tab.
- Select your caching preferences for page, database and minify. If memcached is used this will require you to confirm or modify the default settings and add any additional memcached servers you wish to use. To utilize APC and memcached + memcache installation guides have been provided for those with virtual dedicated or dedicated servers. For those in shared hosting environments, contact your provider to see if either of these are supported.
- If you already have a content delivery network provider, proceed to the CDN Settings tab and populate the fields and set your preferences. If you're not running a version of WordPress with the Media Library feature, use the Media Library Import Tool to migrate your post images etc to appropriate locations.
If you do not have a CDN provider, you can create and use a subdomain instead, e.g. subdomain.domain.com to improve server response, pipelining performance and progressive render.
- On the Minify Settings tab all of the recommended settings are preset. Specify any CSS and JS files in the respective sections, view your site's HTML source and search for .css and .js files. In the case of JS files you can determine the type and location of the embedding using the drop down menu. Avoid the inclusion of packed or obfuscated JS files in this step.
- Enable the plugin on the General Settings tab.
- You're done! Get back to blogging!
Check out the FAQ for more details on usage.
Server Preparation:
Time required: ~1 minute
- Install yum for your operating system if you don't already have it. If you like, you can update all of your installed software, but do so only if you have the experience and time to double check configurations afterwards:
# yum -y update
- Install PECL:
# yum -y install php-pear
- Install the PHP Development package:
# yum -y install php-devel
- Install apxs with the following command:
# yum -y install httpd-devel
Memcached (Daemon) Installation:
Time required: 3 minutes
- Try to install with yum:
# yum -y install libevent
If this succeeds skip to #5. If this fails, then let's compile. Download and extract the latest stable version:
# cd /usr/local/src
# wget http://monkey.org/~provos/libevent-1.4.12-stable.tar.gz
# gunzip -c libevent-1.4.12-stable.tar.gz | tar xf -
# cd libevent-1.4.12-stable
- Let's compile:
# ./configure && make && make install
- In the output you should see:
Libraries have been installed in:
/usr/local/lib
If so you can:
# echo "/usr/local/lib/" > /etc/ld.so.conf.d/libevent.conf
- Configure your server for the new install:
# ldconfig -v
- Now find the latest stable memcached, download and extract:
# cd /usr/local/src
# wget http://memcached.googlecode.com/files/memcached-1.4.0.tar.gz
# gunzip -c memcached-1.4.0.tar.gz | tar xf -
# cd memcached-1.4.0
- Let's compile:
# ./configure && make && make install
- Make sure memcached is starts automatically on server boot:
# touch /etc/init.d/memcached
# echo '#!/bin/sh -e' >> /etc/init.d/memcached
# echo '/usr/local/bin/memcached -d -m 128 -p 11211 -u nobody -l localhost' >> /etc/init.d/memcached
# chmod u+x /etc/init.d/memcached
- And finally, let's start memcached:
# /etc/init.d/memcached
For windows users we recommend checking the following sites for more installation tips:
PECL Memcache Module Installation:
Time required: 2 minutes
- Either use PECL (and skip to #4 if successful):
# pecl install memcache
- Or via compilation. Download the latest stable version and extract:
# cd /usr/local/src/
# wget http://pecl.php.net/get/memcache-2.2.5.tgz
# gunzip -c memcache-2.2.5.tgz | tar xf -
# cd memcache-2.2.5
- Now we start to compile (and copy the module to your PECL modules directory if necessary):
# phpize && ./configure && make && make install
# cp -p /usr/local/src/memcache-2.2.5/modules/memcache.so /usr/lib/php/modules/
- Make sure the module is loaded:
# echo "extension=memcache.so" > /etc/php.d/memcache.ini
or you can also use the memcache.ini file we prepared for you:
# cp -p /var/www/vhosts/domain.com/httpdocs/wp-content/plugins/w3-total-cache/ini/memcache.ini /etc/php.d/
- Finally restart apache:
# /etc/init.d/httpd restart
- You're done! Memcache should now be available. If the following command retuns anything, you're all set:
# php -r 'phpinfo();' | grep 'memcache'
APC Installation via Yum or PECL:
Time required: 1 minute
- Install APC using the PECL command:
# pecl install apc
or using yum:
# yum -y install php-pecl-apc
- Make sure the module is loaded:
# echo "extension=apc.so" > /etc/php.d/apc.ini
or customize /etc/php.d/apc.ini using our included sample config file:
# cp -p /var/www/vhosts/domain.com/httpdocs/wp-content/plugins/w3-total-cache/ini/apc.ini /etc/php.d/
- When ready, restart apache:
# /etc/init.d/httpd restart
- You're done! APC should now be available. If the following command retuns anything, you're all set:
# php -r 'phpinfo();' | grep 'apc'
For windows users we recommend checking the following sites for more installation tips:
APC Installation via Compilation:
Time required: 2 minutes
- Download the latest stable version and extract:
# cd /usr/local/src
# wget http://pecl.php.net/get/APC-3.0.19.tgz
# gunzip -c APC-3.0.19.tgz | tar xf -
# cd APC-3.0.19
- Note the paths returned for the following commands:
# whereis phpize
# whereis php-config
- Use the output from #2 to modify the --with-apxs and --with-php-config flags in the following compile command:
# phpize && ./configure --enable-apc --enable-apc-mmap --with-apxs=/usr/bin/phpize --with-php-config=/usr/bin/php-config && make && make install
The result should be similar to:
Installing shared extensions: /usr/lib/php/modules/
- Use our customed APC settings by overwriting apc.ini in /etc/php.d/:
# cp -p /var/www/vhosts/domain.com/httpdocs/wp-content/plugins/w3-total-cache/ini/apc.ini /etc/php.d/
- Restart apache when ready:
# /etc/init.d/httpd restart
- You're done! APC should now be available. If the following command retuns anything, you're all set:
# php -r 'phpinfo();' | grep 'apc'
Note(s):
- These server instructions are for CentOS, however we can provide others based on your requests.
- In the case where the "Rewrite URL Structure" (in Minify Settings tab) is desired, and apache is not used, the file located in wp-content/plugins/w3-total-cache/wp-content/w3tc-cache/.htaccess contains directives that must be created for the directory: wp-content/uploads/w3tc-cache/.
- Restarting the web server will empty your APC cache, which means it will have to be rebuilt over time and your site's performance will suffer during this period. Still, APC should be installed in any case to maximize WordPress performance.
- Consider using memcached for objects that must persist across web server restarts or that you wish to share amongst your pool of servers (or cluster), e.g.: database objects or page cache.
- Some yum or PECL mirrors may not have your the necessary packages, in such cases you may have to do a manual installation.