How to Install Varnish Cache On Centos 6.8 64 bit

MooseLucifer

Well-known member
Registered
Joined
May 20, 2016
Messages
149
Points
28
Varnish is a cache system is used to speed up the server, especially with large systems and more traffic. Varnish works by caching page content into RAM and immediately returned to the user upon request but not through handling from PHP or MySQL.

Steps to Install Varnish Cache On Centos 6.8 64 bit

Start the install process:

1.Setup varnish repo :
Code:
[root@server ~]# wget http://repo.varnish-cache.org/redhat/varnish-3.0/el6/noarch/varnish-release/varnish-release-3.0-1.el6.noarch.rpm

[root@server ~]# rpm --nosignature -i varnish-release-3.0-1.el6.noarch.rpm
2. Install Varnish and Apache :
Code:
[root@server ~]# yum install varnish -y
[root@server ~]# yum install httpd -y
3. Make both program start at boot :
Code:
[root@server ~]# chkconfig --level 345 varnish on
[root@server ~]# chkconfig --level 345 httpd on
4. Configure apache to listen to port 8080 :
Code:
[root@server ~]# nano /etc/httpd/conf/httpd.conf
- Modify below : Listen 80 to Listen 8080
5. Configuring Varnish Cache :
Code:
[root@server ~]# nano /etc/sysconfig/varnish
- Change VARNISH_LISTEN_PORT=6081 to VARNISH_LISTEN_PORT=80
- Add the following in /etc/varnish/default.vcl :
Code:
[root@server ~]# nano /etc/varnish/default.vcl
Change .port = "80"; to .port = "8080";
6. Start Varnish and Apache :
Code:
[root@server ~]# service varnish start
[root@server ~]#service httpd start
7. verify varnish and Apache running on the correct port :
Code:
[root@server ~]# netstat -plunt
8. Verify the Varnish by running the following command.
Code:
[root@server ~]# curl -I http://127.0.0.1 or domain
9. ApacheBench performance test without Varnish Cache:
Code:
[root@server ~]# ab -k -n 1000 -c 50 http://127.0.0.1:8080/ or domain
Testing Varnish

To know Varnish is working or not you use the command below:

Code:
curl -I domain.com or curl -I http://127.0.0.1
First run, to standard X-Varnish line you will see a number, for example:

for example

Code:
[root@server ~]# curl -I http://127.0.0.1
HTTP/1.1 403 Forbidden
Server: Apache/2.2.15 (CentOS)
Accept-Ranges: bytes
Content-Type: text/html; charset=UTF-8
Content-Length: 4961
Accept-Ranges: bytes
Date: Wed, 07 Sep 2016 12:52:00 GMT
X-Varnish: 1904053775
Age: 0
Via: 1.1 varnish
Connection: keep-alive
Use the command on the 2nd, if it appears 2 Varnish has some activity that is already there, for example:

Code:
X-Varnish: 1904053775
or X-Cache: HIT
Additionally, you can also use two tools:

varnishlog: view Varnish logs in real time
varnishstat: display Varnish cache status

Good luck!
 

jwn

Active member
Hosting Provider
Registered
Joined
Dec 11, 2016
Messages
65
Points
8
Do you also tried with mysql?
 
Older Threads
Latest Threads
Replies
0
Views
20
Replies
0
Views
41
Replies
1
Views
42
Replies
0
Views
237

Latest Hosting OffersNew Reviews

Sponsors

Tag Cloud

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top