Difference between revisions of "Setup Varnish Cache"
(Created page with "==Setting up Varnish Cache with default.vcl== ===What is Varnish Cache?=== Varnish is a web application accelerator. You install it in front of your web application and it w...") |
(→What is Varnish Cache?) |
||
Line 3: | Line 3: | ||
===What is Varnish Cache?=== | ===What is Varnish Cache?=== | ||
− | Varnish is a web application accelerator. You install it in front of your web application and it will speed it up significantly | + | Varnish is a web application accelerator. You install it in front of your web application and it will speed it up significantly. |
+ | |||
+ | Once finished the reader should have a basic Varnish 3.0 cache up and running with the default configuration. | ||
+ | |||
+ | ==Install Varnish YUM Repository== | ||
+ | |||
+ | rpm --nosignature -i http://repo.varnish-cache.org/redhat/varnish-3.0/el6/noarch/varnish-release/varnish-release-3.0-1.el6.noarch.rpm | ||
+ | |||
+ | ==Install Varnish with Yum== | ||
+ | |||
+ | yum install varnish -y | ||
+ | |||
+ | ==Make Varnish start on Boot== | ||
+ | |||
+ | chkconfig varnish on | ||
+ | |||
+ | Now the basic Varnish install is complete, now lets start it | ||
+ | |||
+ | /etc/init.d/varnish start | ||
+ | |||
+ | The default installation of Varnish will start off listening to port 6081 | ||
+ | |||
+ | You will want to adjust this to listen on port 80 so that it will cache incoming web requests. | ||
+ | |||
+ | vi /etc/sysconfig/varnish | ||
+ | |||
+ | Adjust the following value to port 80 | ||
+ | |||
+ | VARNISH_LISTEN_PORT=80 | ||
+ | |||
+ | Now if you have httpd already started will you will want to stop and make httpd listen on another port, example port 81 | ||
+ | |||
+ | sed -i 's/80/81/g' /etc/httpd/conf/httpd.conf | ||
+ | |||
+ | Now restart apache so it will start listen on port 81 | ||
+ | |||
+ | /etc/init.d/httpd restart && /etc/init.d/varnish restart | ||
+ | |||
+ | Now apache will be listing on port 81 and varnish will listen on port 80 | ||
+ | |||
+ | Now you will want to edit you default.vcl file, to tell it use 127.0.0.1:81. | ||
+ | |||
+ | vim /etc/varnish/default.vcl | ||
+ | |||
+ | Change backend to use port 81, by default its set to port 80. | ||
+ | |||
+ | backend default { | ||
+ | .host = "127.0.0.1"; | ||
+ | .port = "81"; | ||
+ | } | ||
+ | |||
+ | Now one last varnish restart, and you are up and running with the default varnish installation | ||
+ | |||
+ | /etc/init.d/varnish restart | ||
+ | |||
+ | Now we check and make sure httpd is listen on port 81 and varnish is listening on port 80 | ||
+ | |||
+ | netstat -nptl | grep -E '80|81' |
Revision as of 00:04, 19 January 2014
Contents
Setting up Varnish Cache with default.vcl
What is Varnish Cache?
Varnish is a web application accelerator. You install it in front of your web application and it will speed it up significantly.
Once finished the reader should have a basic Varnish 3.0 cache up and running with the default configuration.
Install Varnish YUM Repository
rpm --nosignature -i http://repo.varnish-cache.org/redhat/varnish-3.0/el6/noarch/varnish-release/varnish-release-3.0-1.el6.noarch.rpm
Install Varnish with Yum
yum install varnish -y
Make Varnish start on Boot
chkconfig varnish on
Now the basic Varnish install is complete, now lets start it
/etc/init.d/varnish start
The default installation of Varnish will start off listening to port 6081
You will want to adjust this to listen on port 80 so that it will cache incoming web requests.
vi /etc/sysconfig/varnish
Adjust the following value to port 80
VARNISH_LISTEN_PORT=80
Now if you have httpd already started will you will want to stop and make httpd listen on another port, example port 81
sed -i 's/80/81/g' /etc/httpd/conf/httpd.conf
Now restart apache so it will start listen on port 81
/etc/init.d/httpd restart && /etc/init.d/varnish restart
Now apache will be listing on port 81 and varnish will listen on port 80
Now you will want to edit you default.vcl file, to tell it use 127.0.0.1:81.
vim /etc/varnish/default.vcl
Change backend to use port 81, by default its set to port 80.
backend default { .host = "127.0.0.1"; .port = "81"; }
Now one last varnish restart, and you are up and running with the default varnish installation
/etc/init.d/varnish restart
Now we check and make sure httpd is listen on port 81 and varnish is listening on port 80
netstat -nptl | grep -E '80|81'