This guide will briefly go over how to install and configure Varnish Caching. Varnish Cache is a web application accelerator also known as a caching HTTP reverse proxy. You install it in front of any server that speaks HTTP and configure it to cache the contents. It typically speeds up delivery with a factor of 300 – 1000x, depending on your architecture. Please keep in mind that this is a fairly advanced section and does require you to use root access to perform any actions described. Also know that unless you pay for a plugin to do so you can not control varnish from the WHM interface.
This will get Apache ready which should be done prior to the installation to avoid port conflicts.
- Log into your servers command line interface as the root user.
- Edit the following file.vim /var/cpanel/cpanel.config
- Look for the line “apache_port” and change it to the following then save the file.apache_port=0.0.0.0:8081
- Run this command to update the settings./usr/local/cpanel/whostmgr/bin/whostmgr2 –updatetweaksettings
This section will show you how to install Varnish 3 onto your dedicated server.
- Check what version of CentOS you are running by entering the following command.cat /etc/centos-release
CentOS release 6.7 (Final)
- Run the following commands to add the Varnish repositories to your server (Please use the correct command for the current version you are running.).CentOS 6 – rpm –nosignature -i https://repo.varnish-cache.org/redhat/varnish-3.0/el6/noarch/varnish-release/varnish-release-3.0-1.el6.noarch.rpmCentOS 5 – rpm –nosignature -i https://repo.varnish-cache.org/redhat/varnish-3.0/el5/noarch/varnish-release/varnish-release-3.0-1.el5.centos.noarch.rpm
- Install Varnish via yum.yum install varnish
- Edit the following file.vim /etc/sysconfig/varnish
- Add the following lines to the bottom of the file (After the # DAEMON_OPTS=”” line).DAEMON_OPTS=”-a :80 \
-T localhost:6082 \
-b localhost:8081 \
-u varnish -g varnish \
- Save the file.
- Restart the following services for the changes to take affect.service varnish restart
service httpd restart
This configuration does the following:
- Listen on all IP addresses on port 80
- Set the administrative interface on port 6082 (the default)
- Forward requests to localhost on port 8081 (Apache server we changed earlier)
- Set the user/group for child processes to varnish:varnish
- Use the file storage mechanism at /var/lib/varnish/varnish_storage.bin and use only 2GB for the file.