- 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 :
2. Install Varnish and Apache :
3. Make both program start at boot :
4. Configure apache to listen to port 8080 :
5. Configuring Varnish Cache :
- Add the following in /etc/varnish/default.vcl :
6. Start Varnish and Apache :
7. verify varnish and Apache running on the correct port :
8. Verify the Varnish by running the following command.
9. ApacheBench performance test without Varnish Cache:
Testing Varnish
To know Varnish is working or not you use the command below:
First run, to standard X-Varnish line you will see a number, for example:
for example
Use the command on the 2nd, if it appears 2 Varnish has some activity that is already there, for example:
Additionally, you can also use two tools:
varnishlog: view Varnish logs in real time
varnishstat: display Varnish cache status
Good luck!
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
Code:
[root@server ~]# yum install varnish -y
[root@server ~]# yum install httpd -y
Code:
[root@server ~]# chkconfig --level 345 varnish on
[root@server ~]# chkconfig --level 345 httpd on
Code:
[root@server ~]# nano /etc/httpd/conf/httpd.conf
- Modify below : Listen 80 to Listen 8080
Code:
[root@server ~]# nano /etc/sysconfig/varnish
- Change VARNISH_LISTEN_PORT=6081 to VARNISH_LISTEN_PORT=80
Code:
[root@server ~]# nano /etc/varnish/default.vcl
Change .port = "80"; to .port = "8080";
Code:
[root@server ~]# service varnish start
[root@server ~]#service httpd start
Code:
[root@server ~]# netstat -plunt
Code:
[root@server ~]# curl -I http://127.0.0.1 or domain
Code:
[root@server ~]# ab -k -n 1000 -c 50 http://127.0.0.1:8080/ or domain
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
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
Code:
X-Varnish: 1904053775
or X-Cache: HIT
varnishlog: view Varnish logs in real time
varnishstat: display Varnish cache status
Good luck!