How To Set Up W3 Total Cache With Template

From OpenLiteSpeed Wiki

Revision as of 15:16, 27 July 2016 by Jackson (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This wiki is outdated and an archive version only.

Templates are an easy way to set up OpenLiteSpeed for various uses. In the following article we will guide you through the steps to set up virtual hosts running W3 Total Cache, "the highest rated and most complete WordPress performance plugin". The first part of this article will cover importing the template. After the template is imported, you just need to create virtual hosts for each domain you want to run with WP Super Cache and install WordPress and WP Super Cache in those virtual hosts.

Note: Any setting not specifically noted in this walkthrough can be left as the default.

Import the W3 Total Cache template

1. Download the W3 Total Cache template file.

2. Save the template file to /usr/local/lsws/conf/templates/w3totalcache.conf.

3. Make sure user lsadm has write permission.

chown lsadm /usr/local/lsws/conf/templates/w3totalcache.conf

4. Add the template on the WebAdmin console.

WebAdmin console > Configuration > Virtual Host Templates > Add
Template Name: w3totalcache (name it anything as long as it does not conflict with existing templates)
Template File: $SERVER_ROOT/conf/templates/w3totalcache.conf
Mapped Listeners: Default
Note: In order for the server to direct traffic to the proper vhost, you must have listeners set up to listen on the proper IP and port. When you use a virtual host template, you do not have to define listener-to-virtual host mappings in the listener settings. Instead you set the mapped listeners when adding a template. In the above settings, we have used the listener "Default", which is set up to listen on port 8088 of "ANY" IP by default. You must adjust your listener settings to make sure there are listeners on the IP and ports you need. (The easiest way to do this is for most sites to just change the port setting to "80" for the Default listener in WebAdmin console > Configuration > Listeners > Default > General. This gives you a listener listening on port 80 of all IPs.)

5. Graceful restart to apply changes. (Actions > Graceful Restart)

Set up virtual hosts using this template

1. Create a member virtual host from the template.

WebAdmin console > Configuration > Virtual Host Templates > w3totalcache > Member Virtual Hosts > Add
Virtual Host Name: totalcache1
Note: We have named our WP Super Cache vhost "totalcache1". You can name it whatever you want, but remember to then replace any instances of "totalcache1" in this tutorial with the name of your virtual host.

2. Create directories for this vhost.

As the root user, run the following commands:
mkdir /usr/local/lsws/totalcache1
mkdir /usr/local/lsws/totalcache1/{html,logs,conf}
chown lsadm:lsadm /usr/local/lsws/totalcache1/conf

3. Graceful restart to apply changes. (Actions > Graceful Restart)

Your new vhost is now live and ready for WordPress and W3 Total Cache. All you have to do is install them.

Install WordPress

1. RPM install.

yum install mysql mysql-devel mysql-server libxml2-devel libmcrypt-devel libtidy-devel gd-devel gcc gcc-c++ make patch

2. Build PHP.

We're going to be building PHP (5.3.25, for example) with additional modules and configurations for use with W3 Total Cache.
Go to the WebAdmin Console > Actions > Compile PHP
'--with-mysqli' '--with-zlib' '--with-gd' '--enable-shmop' '--enable-track-vars' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-magic-quotes' '--enable-mbstring' '--with-iconv' '--with-mysql' '--with-libdir=lib64'

Note: '--with-libdir=lib64' is for x86_64 systems.

Check the "XCache (Opcode Cache)" and "pecl/memcache (memcached extension)" boxes in the WebAdmin's PHP Build Options, as well.

6. Graceful restart to apply changes. (Actions > Graceful Restart)

3. Download WordPress into your virtual host document root: /usr/local/lsws/totalcache1/html

cd /usr/local/lsws/totalcache1/html

4. Grant the web server user write permission for WordPress W3 Total Cache installation.

chown -R nobody wordpress

5. Set up a MySQL database and user for WordPress.

Instructions can be found at

6. Graceful restart to apply changes. (Actions > Graceful Restart)

7. Point your browser to http://server_ip:8088/wordpress/wp-admin/install.php to run the WordPress installer.

Install and configure W3 Total Cache

1. In the WordPress dashboard, go to Plugins > Add New. Search for W3 Total Cache and install it.

2. Once W3 Total Cache is installed and activated, go to the plugin admin page (Performance > General Settings), and configure it as follows:

Page Cache
Page cache method: Disk: Enhanced

Minify mode: Manual
Minify cache method: Disk
HTML minifier: Default
JS minifier: JSMin (default)
CSS minifier: Default

Database Cache
Database Cache Method: Opcode: XCache

Object Cache
Object Cache Method: Disk
Debug Mode: Page Cache, Minify, Database Cache, Object Cache

3. If a page is served from cache (and the debug settings are set), it will have a signature at the end of response page similar to the one below: (This signature is only visible when viewing the source.)

<!-- W3 Total Cache: Minify debug info:
Engine:             disk
Theme:              0dec3
Template:           single

<!-- W3 Total Cache: Page cache debug info:
Engine:             disk: enhanced
Cache key:
Caching:            enabled
Creation Time:      0.098s
Header info:
X-Powered-By:        PHP/5.3.25
X-W3TC-Minify:       On
Last-Modified:       Thu, 13 Jun 2013 00:28:32 GMT
Content-Type:         text/html; charset=UTF-8