How to Activate Varnish Cache Server on CWP

Sunday, December 28th 2014. | how to

#howto ,#tutorial #VPS – How to Activate Varnish Cache Server on CWP – This tutorial explains step by step guide (with pics) about How to Activate Varnish Cache Server on CWP

What interested me from CWP is that the software comes with LAMP plus Varnish, a powerful reputable frontend caching engine to boost your website loading speed and reduce server’s CPU load. User can choose either Disk-based or RAM-based caching mechanism. However if your server / VPS has a generous amount of RAM, you can allocate part of it for Varnish to store its cache files. RAM-based caching is however faster than Disk, even an SSD.

During initial install, CWP will only install and enable full LAMP stack while Varnish need is not. Hence, you’ll need additional steps to get it installed, activated and configured properly. But do not worry so much because installing Varnish on CentOS Web Panel can be done in one click (unlike zPanel that you have to install it manually).

Are you ready? Here’s what you’ll need for:

  1. First, install CWP on your server following my previous guide.
  2. Do some basic configuration tasks.
  3. Login to CWP admin page as root or as user with root privilege via:
    http://ip-address:2030

Next, follow these steps to install and configure Varnish on CentOS Web Panel:

Step 1 – Go to Apache Settings then Varnish Cache Server.

cwp-varnish

Step 2 – You’ll then see a message saying that Varnish is not installed (yet). Now click on the blue Install Varnish button.

cwp-install-varnish

In the next page, you can see all the install process like following:

Preparing...                ##################################################
varnish-release             ##################################################
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: repos.mia.quadranet.com
 * extras: repos.mia.quadranet.com
 * rpmforge: mirror.teklinks.com
 * updates: repos.mia.quadranet.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package varnish.x86_64 0:3.0.6-1.el6 will be installed
--> Processing Dependency: varnish-libs = 3.0.6-1.el6 for package: varnish-3.0.6-1.el6.x86_64
--> Processing Dependency: libvarnishapi.so.1(LIBVARNISHAPI_1.0)(64bit) for package: varnish-3.0.6-1.el6.x86_64
--> Processing Dependency: libvarnishapi.so.1()(64bit) for package: varnish-3.0.6-1.el6.x86_64
--> Running transaction check
---> Package varnish-libs.x86_64 0:3.0.6-1.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package             Arch          Version             Repository          Size
================================================================================
Installing:
 varnish             x86_64        3.0.6-1.el6         varnish-3.0        444 k
Installing for dependencies:
 varnish-libs        x86_64        3.0.6-1.el6         varnish-3.0         42 k

Transaction Summary
================================================================================
Install       2 Package(s)

Total download size: 485 k
Installed size: 1.2 M
Downloading Packages:
--------------------------------------------------------------------------------
Total                                           215 kB/s | 485 kB     00:02     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction

  Installing : varnish-libs-3.0.6-1.el6.x86_64                              1/2 

  Installing : varnish-3.0.6-1.el6.x86_64                                   2/2 

  Verifying  : varnish-3.0.6-1.el6.x86_64                                   1/2 

  Verifying  : varnish-libs-3.0.6-1.el6.x86_64                              2/2 

Installed:
  varnish.x86_64 0:3.0.6-1.el6                                                  

Dependency Installed:
  varnish-libs.x86_64 0:3.0.6-1.el6                                             

Complete!

Step 3 – It is time to setup few configuration so Varnish can run properly. By default, the configuration is set as following:

Varnish port is set to: 6081 in: /etc/sysconfig/varnish
Apache IP is set to 127.0.0.1 in Varnish config file: /etc/varnish/default.vcl
Apache port is set to 80 in Varnish config file: /etc/varnish/default.vcl

Normally as per my previous guide, if you installed it manually then you have to edit each of Varnish configuration including its .vcl files. Thanks to CWP, you can now configure it via a web-based user interface so you don’t even need to open Putty and do the task via command line interface.

Now scroll down that page a little bit and you will see a form where you can adjust its value.

cwp-varnish-config

Simply edit as recommended except the Varnish Storage Size because you need to adjust the value according the your server’s RAM. If your VPS has only 1GB of RAM, you can allocate 512MB max for Varnish. Of course you can make it less than 512MB. In my case I will allocate 256MB.

cwp-varnish-conf-ok

Once you clicked the Save Changes button, you’ll see several lines of message like below:

cwp-varnish-done

The first part means CWP has updated all Virtual Host entries adjusting its port to 82 (Apache). The next part just tells you that Apache has restarted and Varnish is running. That’s it.

Now you can use your other server to check its header using CURL command:

varnish-meta-curl

See? Enjoy the speed of Varnish without the complicated part.

This post How to Activate Varnish Cache Server on CWP is part of ServerMom.

Source link