WordPress + Super Cache plugin for Centmin Mod Nginx

This is a WordPress test blog install for Centmin Mod Nginx web stack on a RamNode 128MB OpenVZ VPS server consisting of:

How to install WordPress + WordPress Super Cache on Centmin Mod Nginx

1. On your Centmin Mod Nginx installed server, install the WP-CLI Addon.

2. Create MySQL database, MySQL username and password and grant privileges to the created MySQL database. Where:

  • MySQL database name = domain1v381
  • MySQL username = domain1username
  • MySQL password = yourmysqlpass

3. Create your Nginx vhost if you haven’t already via centmin.sh menu option #2 – Add Nginx vhost domain (details here). For this example, domain = yourdomain.com. At end of vhost creation you will get listed information regarding where your Nginx vhost conf file is located, where your public web root is located for file uploads and where your Nginx vhost log file directory is located.

  • vhost conf file for yourdomain.com created: /usr/local/nginx/conf/conf.d/yourdomain.com.conf
  • upload files to /home/nginx/domains/yourdomain.com/public
  • vhost log files directory is /home/nginx/domains/yourdomain.com/log

Take note of these locations as you will need them for WordPress installation next.

4. Install WordPress via WP-CLI command line tool in SSH.

You will install WordPress using the WP-CLI command line tool you installed in step 1 above. It’s basically a list of commands to download WordPress latest files, configure your wp-config.php, then install WordPress itself. No need to use SFTP or upload any files at all. It’s all done straight from SSH client window !

The commands need to be run from your Nginx domain’s vhost at location where you want to install WordPress. For instance, you want WordPress installed at yourdomain.com, so would need to use web root path at /home/nginx/domains/yourdomain.com/public. If you wanted to install WordPress at yourdomain.com/wp, you would use /home/nginx/domains/yourdomain.com/public/wp.

Commands are as follows for WordPress installed at yourdomain.com  – paying attention to wp core config parameters for –dbname, –dbuser, –dbpass and for wp core install parameters for –url, –title, –admin_email, –admin_password and –admin_name ensuring they match your intended details:

5. Installing WordPress Super Cache plugin + list of recommended WordPress plugins via WP-CLI command line tool.

Still within your WordPress installation directory at /home/nginx/domains/yourdomain.com/public, type the following commands to install + activate the WordPress plugins:

Then some additional commands to ensure permissions and WordPress Super Cache are setup correctly. Still done within your WordPress installation directory at /home/nginx/domains/yourdomain.com/public:

6. Centmin Mod Nginx vhost format and create php.conf include file specifically for WordPress Super Cache.

Create WordPress Super Cache specific php.conf include file named php-wpsc.conf by making a copy of the existing php.conf making a sed replacement change to php-wpsc.conf.

Nginx vhost format for web root WordPress install at /. Edit /usr/local/nginx/conf/conf.d/yourdomain.com.conf to below format:

Then create file at /usr/local/nginx/conf/wpsecure.conf with following contents:

Then create file at /usr/local/nginx/conf/wpsupercache.conf with following contents:

If wordpress installed in subdirectory i.e. /wordpress, you meed top add /wordpress in front of ($request_uri ~* “/wordpress/(wp-admin/.

7.  Then you need to login WordPress admin and do the following:

  1. Enable Permalinks
  2. Go to Super Cache plugin Easy tab and enable it by checking ” Caching On (Recommended)” and hit Update Status
  3. Then go to Advanced tab and check “Use mod_rewrite to serve cache files. (Recommended)” and hit Update Status

Then confirm WP Super Cache is working by checking page source code on WordPress pages via SSH window type the following if WordPress installed at http://yourdomain.com/. To properly test for WP Super Cache you need to clear all related site browser cookies and be logged out to properly test.

you’ll see output like below

8. Screenshots for WP-CPI installed and activated WordPress Plugins

Auto installed and activated WordPress plugins

Acunetix default security alerts

Enabling security settings

Security alerts after enabling settings – almost all green !

Protection against brute force WordPress login attempts

Sucuri WordPress Integrity Check options as well as many other options to dig into.

WordPress Updates Notifier Plugin – get email notifications when WordPress updates for plugins and themes are available !

WordPress Super Cache


The question has come up as to which is better method for combining js/css files, using Nginx Pagespeed or Autoptimize WordPress Plugin. It all comes down to trial and error and depends on your WP theme you are using and it’s js/css elements etc. Super Cache method is definitely the best for ease of use and relatively good success rate in implementing as per http://wp1.centmincache.com/1.

As to Nginx Pagespeed and Autoptimize both allow you to exclude specific js and css files from being combined so if you have problems with your WordPress theme and the use of either Nginx PageSpeed or Autoptimize.

  • For pagepseed read user guide at https://developers.google.com/speed/pagespeed/module/using and how to disallow elements/urls  https://developers.google.com/speed/pagespeed/module/restricting_urls. You would enter the pagespeed Disallow entries into your /usr/local/nginx/conf/pagespeed.conf outlined here. The pagespeed.conf can be accessed via nano text editor via the shortcut command = pscontrol edit. After adding and editing your pagespeed.conf, you would need to restart Nginx web server for the changes to take effect. You can enable Nginx Pagespeed Console and message logging to double check which files are excluded or processed by Nginx Pagespeed as outlined in how to enable Pagespeed Console section. Then once enabled, check your message log at yourdomain.com/ngx_pagespeed_message
  • For Autoptimize, the settings page allows you to enter specific names of css or js files to exclude and you would enter accordingly to your WP theme’s js and css elements.

Use your browser’s developer tools to be able to view all your elements that load on your pages or use webpagetest.org and gtmetrix.com to view the elements/requests for your pages. Here’s a test result for webpagetest.org for this WordPress blog available at http://www.webpagetest.org/result/140503_7G_99dbaf955227dd67bf88c6c26ce879c8/.

Author: centminmod

Share This Post On