Home > HowTo, Linux, Varnish > varnish for wordpress

varnish for wordpress

November 10th, 2017 Leave a comment Go to comments

So I came back to using varnish over my wordpress server. Just got tired of php-cgi 100% CPU and getting 503 errors.

Varnish is the best and f** the rest….

This is a simple guide to use Varnish with wordpress:
(Varnish 4.1 on linux ami, or linux centos/redhat)

Lets install varnish via repo
/etc/yum.repos.d/varnish.repo

[varnishcache_varnish41]
name=varnishcache_varnish41
baseurl=https://packagecloud.io/varnishcache/varnish41/el/6/$basearch
repo_gpgcheck=1
gpgcheck=0
enabled=1
gpgkey=https://packagecloud.io/varnishcache/varnish41/gpgkey
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300

OK, ready then

yum clean all
yum install varnish

Check the version:

# /usr/sbin/varnishd -V
varnishd (varnish-4.1.8 revision d266ac5c6)

here is my varnish default configuration
/etc/sysconfig/varnish

NFILES=131072
MEMLOCK=2000
NPROCS="unlimited"
RELOAD_VCL=1
VARNISH_VCL_CONF=/etc/varnish/default.vcl
VARNISH_LISTEN_PORT=80
VARNISH_ADMIN_LISTEN_ADDRESS=127.0.0.1
VARNISH_ADMIN_LISTEN_PORT=6082
VARNISH_SECRET_FILE=/etc/varnish/secret
VARNISH_MIN_THREADS=20
VARNISH_MAX_THREADS=500
VARNISH_STORAGE_FILE=/var/lib/varnish/varnish_storage.bin
VARNISH_STORAGE_SIZE=1G
VARNISH_STORAGE="file,${VARNISH_STORAGE_FILE},${VARNISH_STORAGE_SIZE}"
#VARNISH_STORAGE="malloc,${VARNISH_STORAGE_SIZE}"
VARNISH_TTL=60
DAEMON_OPTS="-a ${VARNISH_LISTEN_ADDRESS}:${VARNISH_LISTEN_PORT} \
-f ${VARNISH_VCL_CONF} \
-T ${VARNISH_ADMIN_LISTEN_ADDRESS}:${VARNISH_ADMIN_LISTEN_PORT} \
-p thread_pool_min=${VARNISH_MIN_THREADS} \
-p thread_pool_max=${VARNISH_MAX_THREADS} \
-S ${VARNISH_SECRET_FILE} \
-s ${VARNISH_STORAGE}"

And the Varnish VCL is here:

  1. No comments yet.

VAMOVE *

*