amuck-landowner

Setup, configure and Install Varnish Cache server 3.0.5 in CentOS 6.5

S4S-UK

New Member
Moderator HEP

Pie here! Editing this thread to provide source as to where User S4S-UK copied this tutorial from.

Source: http://www.fun2friend.com/topic/66147-install-setup-varnish-cache-in-centos-65/

-----------

Setup, configure and Install Varnish Cache server 3.0.5
in CentOS 6.5
You can also use this guide within your CentOS 5.x.x and 6.x.x versions.
Varnish cache server 3.0.5 is the latest stable release. Centos 6.5 is latest stable release. I installed this in my company VPS so i decide to share with needed peoples who actually just miss-understood its simple configuration.
Just follow the Steps and you will get the results.

First install latest version RPM by run the following command

If you are on RHEL and CentOS 5 or a compatible distribution, use

rpm --nosignature -i http://repo.varnish-cache.org/redhat/varnish-3.0/el5/noarch/varnish-release/varnish-release-3.0-1.el5.centos.noarch.rpm

For RHEL and CentOS 6 and compatible distributions, use

rpm --nosignature -i http://repo.varnish-cache.org/redhat/varnish-3.0/el6/noarch/varnish-release/varnish-release-3.0-1.el6.noarch.rpm

and then run

yum install varnish

Once it installed successfully you need to run the followng command.

chkconfig --level 345 varnish on

Now you just need to first Finalise two thing.

1. Change the Apache port from 80 to 8080

2. Define the webserver or you can say you Main server IP within Varnish configuration file in /etc/sysconfig/varnish

EDIT FILE:

nano /etc/sysconfig/varnish

You will find this part in the file which is "Alternative 3" example that varnish by default use. its best and optimise setting. Just notet the changes that i made like Port and IP in the below area. you need to made it with your own IP.

## Alternative 3, Advanced configuration## See varnishd(1) for more information.### Main configuration file. You probably want to change it:)

VARNISH_VCL_CONF=/etc/varnish/default.vcl

### Default address and port to bind to## Blank address means all IPv4 and IPv6 interfaces, otherwise specify## a host name, an IPv4 dotted quad, or an IPv6 address inbrackets.

VARNISH_LISTEN_ADDRESS=11.22.33.44

VARNISH_LISTEN_PORT=80

Notice two last line with IP it was before like this

#VARNISH_LISTEN_ADDRESS=

VARNISH_LISTEN_PORT=6081

Remove the hash # and define VPS Main IP here on which Apache run. once done, hit Control+O to save then Control+X to exit from nano.

Now open second Varnish default.vcl file for defining the port for Apache connectivity.

EDIT FILE:

nano /etc/varnish/default.vcl

Find this part in the file

backend default{.host ="127.0.0.1";.port ="80";}

change the port 80 to 8080. hit Control+O to save then Control+X to exit from nano.

Now your Varnish cache web accelerator is configure on port 80 and connect with Apache server on port 8080. Now we only need to configure Apache on port 8080 on localhost IP than main VPS IP.

Open Apache default configuration file:

nano /etc/httpd/conf/httpd.conf

and change your IP with 127.0.0.1 and port with 8080. it will exactly look like this below image after the change.

listen-port-8080.jpg

once done, hit Control+O to save then Control+X to exit from nano.

inCase, you use virtual host so you need to change the virtual host IP and port same like above image.

Now its time to restart Both services for effect. First Apache service and after that Varnish service. so run the following commands.

service httpd restart

service varnish restart

Now run the following command to check Varnish is work fine OR not.

curl -I http://www.fun2friend.com

change fun2friend.com with your website that run from the same server.

Output should be like

HTTP/1.1200 OK

Server:ApacheSet-Cookie:

session_id=fb2dede70fee22fac1b5924f0d1bc362; path=/; domain=fun2friend.com;

httponlyVary:Accept-EncodingContent-Type: text/html;charset=UTF-8Date:Sat,25Jan201418:32:27 GMT

X-Varnish:1600569958Age:0Via:1.1 varnish

Connection: keep-alive

You can notice it shows "Via: 1.1 varnish" that proof varnish works abslutely fine.

Few varnish usefull commands for performance check and advance things check.

For Varnish performance check, RUN

varnishstat

Common commands with description

# varnishstat : Provides all the info you need to spot cache misses and errors.

# varnishhist : Provides a histogram view of cache hits/misses.

# varnishlog : Provides detailed information on requests.

# varnishtop : It reads varnishd shared memory logs and presents a most commonly occurring log entries.

# varnishadm : Command-line varnish administration used to reload vcl and purge urls.
 Courtesy Internet

-----------

Moderator HEP

Source: http://www.fun2friend.com/topic/66147-install-setup-varnish-cache-in-centos-65/
 
Last edited by a moderator:

HalfEatenPie

The Irrational One
Retired Staff
I edited the original thread to provide source to original source. 

I think this is right but if it isn't let me know :)
 

abyssis

New Member
I edited the original thread to provide source to original source. 

I think this is right but if it isn't let me know :)
I don't personally think there is anything wrong with it, but at least @S4S-UK could have kept the original "highlights" since this is rather confusing and hard to read.
 
Last edited by a moderator:

HalfEatenPie

The Irrational One
Retired Staff
I don't personally think there is anything wrong with it, but at least @S4S-UK could have kept the original "highlights" since this is rather confusing and hard to read.
Just trying to give credit where credit is due ;) People put in their time and effort to get tutorials like these made. Copying and pasting it from somewhere else and claiming it as your own is a total jerk move for those people. It's just like saying you did this research and got these results when you in fact stole those results from another researcher. It's not professional (and in the academic world is a major no-no and a black mark on your professional career).
 
Last edited by a moderator:

abyssis

New Member
Just trying to give credit where credit is due ;) People put in their time and effort to get tutorials like these made. Copying and pasting it from somewhere else and claiming it as your own is a total jerk move for those people. It's just like saying you did this research and got these results when you in fact stole those results from another researcher. It's not professional (and in the academic world is a major no-no and a black mark on your professional career).
I think you misunderstood. This was not aimed against you and I'm completely against copy/pasting. What I was trying to say is that he should have at least kept the same formatting due to better readability, because this way it's rather confusing in my opinion.
 

S4S-UK

New Member
Just trying to give credit where credit is due ;) People put in their time and effort to get tutorials like these made. Copying and pasting it from somewhere else and claiming it as your own is a total jerk move for those people. It's just like saying you did this research and got these results when you in fact stole those results from another researcher. It's not professional (and in the academic world is a major no-no and a black mark on your professional career).
sorry for that, But did not take any credit or neither i say its my, this is other thing the website fun2friend is link to my website (humyouth) you can search in google beacse its my personal website
 
Last edited by a moderator:

Raymii

New Member
How much of a difference does Varnish make for load? How does it compare to something like W3 total cacle + memcahced for example?
 

datarealm

New Member
Verified Provider
How much of a difference does Varnish make for load? How does it compare to something like W3 total cacle + memcahced for example?
Its another tool for your arsenal.. It should not replace other tools you are using.  (For example you'll still want memcached for handling your sessions.)

Varnish can have a HUGE impact on a high traffic site.  I love this article:

http://ewan.im/900/10-million-hits-a-day-with-wordpress-using-a-15-server

We employed something similar for a client who could not keep his wordpress site online.  When we were done varnishstat was reporting around 300 client_req and he was humming along just fine.
 
Top
amuck-landowner