How to Install Varnish on CentOS 7 or RHEL 7
- Category : Linux Helpline (Easy Guide)
- Posted on : Mar 02, 2019
- Views : 1,817
- By : Vucebte Q.
1. Introduction
Varnish is a proxy and cache, or HTTP accelerator, designed to improve performance for busy, dynamic web sites. By redirecting traffic to static pages, varnish reduces the number of dynamic page calls, thus reducing load. Varnish is designed for content-heavy dynamic web sites as well as heavily consumed APIs. In contrast to other web accelerators, such as Squid, or Apache and nginx, which are primarily origin servers, Varnish was designed as an HTTP accelerator.
2. Varnish Cache Performance Parameters
Once installed, Varnish Cache allows us to use several apps to evaluate the server by means of statistics. These apps are the ones mentioned below.
- varnishtop: grouped list with the most usual entries from different logs.
- varnishhist: a histogram that shows the time taken for the requests processing.
- varnishsizes: it performs the same task as “varnishhist” but showing the size of the objects.
- varnishstat: it shows many contents on cache hits, resource consumption, etc..
- varnishlog: it allows us to see all the requests made to the web backend server.
3. Requirements
You may need an operating system RHEL 7 or Centos 7 in your dedicated or vps server. Please make sure to set a hostname for your server and its dns is pointing to the IP address of the server.
4. Installation Steps
Before you begin please install LAMP(Linux Apache Mysql PHP) in your server. To install LAMP, Please refer the documentation from here
Update your server with latest packages.
# yum update
Now install varnish on Centos.
# yum install varnish
4.1 How to setup Varnish 4 for Apache
# vi /etc/varnish/varnish.params
Change Listen Port to 80 as we are going to run Varnish in front of Apache:
VARNISH_LISTEN_PORT=80
Now edit Apache configuration file:
# vi /etc/httpd/conf/httpd.conf
Then look for the line that says “Listen 80” and change it to “Listen 8080”
Now restart Apache at first so the webserver run on port 8080 leaving port 80 being usable by Varnish:
# systemctl restart httpd.service
# systemctl restart varnish.service
# systemctl enable varnish.service
You can see varnish running on port 80 using the following command:
# netstat -tunlp | grep :80 tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 22368/httpd tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 22145/varnishd
5. Testing varnish
# varnishd -V
Gives you an output something like this:
varnishd (varnish-3.0.7 revision f544cd8) Copyright (c) 2006 Verdens Gang AS Copyright (c) 2006-2014 Varnish Software AS
You can check it like this
# curl -I # curl -I 192.168.3.18 HTTP/1.1 403 Forbidden Date: Sun, 17 Jan 2016 10:42:54 GMT Server: Apache/2.4.6 (CentOS) PHP/5.4.16 Last-Modified: Thu, 16 Oct 2014 13:20:58 GMT ETag: "1321-5058a1e728280" Accept-Ranges: bytes Content-Length: 4897 Content-Type: text/html; charset=UTF-8 X-Varnish: 13 Age: 0 Via: 1.1 varnish-v4 Connection: keep-alive
Categories
- cPanel Question 47
- cPanel Software Management 29
- cPanel Tutorials 13
- Development 29
- Domain 13
- General 19
- Linux Helpline (Easy Guide) 156
- Marketing 47
- MySQL Question 13
- News 2
- PHP Configuration 14
- SEO 4
- SEO 42
- Server Administration 84
- SSL Installation 54
- Tips and Tricks 24
- VPS 3
- Web Hosting 44
- Website Security 22
- WHM questions 13
- WordPress 148
Subscribe Now
10,000 successful online businessmen like to have our content directly delivered to their inbox. Subscribe to our newsletter!Archive Calendar
Sat | Sun | Mon | Tue | Wed | Thu | Fri |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 | 31 |
Recent Articles
-
Posted on : Sep 17
-
Posted on : Sep 10
-
Posted on : Aug 04
-
Posted on : Apr 01
Tags
- ts
- myisam
- vpn
- sql
- process
- kill
- tweak
- server load
- attack
- ddos mitigation
- Knowledge
- layer 7
- ddos
- webmail
- DMARC
- Development
- nginx
- seo vpn
- Hosting Security
- wireguard
- innodb
- exim
- smtp relay
- smtp
- VPS Hosting
- cpulimit
- Plesk
- Comparison
- cpu
- encryption
- WHM
- xampp
- sysstat
- optimize
- cheap vpn
- php-fpm
- mariadb
- apache
- Small Business
- Error
- Networking
- VPS
- SSD Hosting
- Link Building
- centos
- DNS
- optimization
- ubuntu