How to install Varnish cache 5.1 on CentOS 7
How to install Varnish cache 5.1 on CentOS 7
Varnish cache is a powerful open source HTTP reverse engine proxy that can speed up a website by using fewer backend server resources and keeps a copy of webpage the first time a user visits. The Varnish cache visits the server once to cache the page and then all the future requests will be served by the varnish cache for the same page. It is engineered for excessively utilized API endpoints and also for dynamic sites that serve massive-content and experience high-traffic. This tutorial covers the installation procedure of Varnish cache 5.1 on CentOS 7.
Installation procedure
To start with the installation procedure, install the Apache HTTP server in CentOS by running the yum command.
[root@linuxhelp Desktop]# yum install httpd
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirror.nbrc.ac.in
.
.
Installed:
httpd.x86_64 0:2.4.6-45.el7.centos.4
Dependency Installed:
apr.x86_64 0:1.4.8-3.el7 apr-util.x86_64 0:1.5.2-6.el7
httpd-tools.x86_64 0:2.4.6-45.el7.centos.4 mailcap.noarch 0:2.1.41-2.el7
Complete!
Next start and enable the HTTPD services by executing the following command.
[root@linuxhelp Desktop]# systemctl start httpd [root@linuxhelp Desktop]# systemctl enable httpd
Update the system firewall rules to permit the HTTP service.
[root@linuxhelp Desktop]# firewall-cmd --zone=public --permanent --add-service=http
Success
After adding the rule, reload the firewall by running the following command.
[root@linuxhelp Desktop]# firewall-cmd --reload
Success
Now install the epel repository and press y to continue the installation procedure.
[root@linuxhelp Desktop]# yum install -y epel-release
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
.
.
Installed:
epel-release.noarch 0:7-9
Complete!
The epel repository is installed in the target system. Now install the required dependency packages and execute the following command.
[root@linuxhelp Desktop]# yum install autoconf automake jemalloc-devel libedit-devel libtool ncurses-devel pcre-devel pkgconfig python-docutils python-sphinx graphviz -y
Loaded plugins: fastestmirror, langpacks
epel/x86_64/metalink | 6.2 kB 00:00
epel | 4.3 kB 00:00
.
.
Dependency Updated:
glibc.x86_64 0:2.17-157.el7_3.5 glibc-common.x86_64 0:2.17-157.el7_3.5
libgcc.x86_64 0:4.8.5-11.el7 libgomp.x86_64 0:4.8.5-11.el7
pcre.x86_64 0:8.32-15.el7_2.1
Complete!
The packages are installed in the target system. Next download the Varnish package by running the wget command followed by the download link.
[root@linuxhelp Desktop]# wget https://repo.varnish-cache.org/source/varnish-5.1.2.tar.gz
--2017-08-03 23:09:18-- https://repo.varnish-cache.org/source/varnish-5.1.2.tar.gz
.
.
100%[======================================> ] 2,597,817 43.8KB/s in 53s
2017-08-03 23:10:12 (47.5 KB/s) - ‘ varnish-5.1.2.tar.gz’ saved [2597817/2597817]
Extract the downloaded varnish package using tar command.
[root@linuxhelp Desktop]# tar -zxvf varnish-5.1.2.tar.gz
varnish-5.1.2/
varnish-5.1.2/aclocal.m4
varnish-5.1.2/autogen.sh
varnish-5.1.2/varnishapi-uninstalled.pc.in
.
.
varnish-5.1.2/lib/libvmod_directors/fall_back.c
varnish-5.1.2/lib/libvmod_directors/shard_hash.h
Enter into the extracted varnish directory by executing the cd command.
[root@linuxhelp Desktop]# cd varnish-5.1.2/ [root@linuxhelp varnish-5.1.2]#
List the files in the extracted directory by running the ls command.
[root@linuxhelp varnish-5.1.2]# ls
aclocal.m4 configure lib README.Packaging
autogen.sh configure.ac LICENSE README.rst
bin doc m4 varnishapi.pc.in
build-aux etc Makefile.am varnishapi-uninstalled.pc.in
ChangeLog include Makefile.in varnish-legacy.m4
config.h.in INSTALL man varnish.m4
Next run the autogen.sh command to generate the automatic configuration.
[root@linuxhelp varnish-5.1.2]# sh autogen.sh
+ libtoolize --copy --force
libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, `build-aux' .
.
.
+ autoconf
You have new mail in /var/mail/root
Run the configuration process by executing the following command.
[root@linuxhelp varnish-5.1.2]# sh configure
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
.
.
config.status: executing depfiles commands
config.status: executing libtool commands
config.status: executing mkdir commands
Compile the package using make command.
[root@linuxhelp varnish-5.1.2]# make
make all-recursive
make[1]: Entering directory `/root/Desktop/varnish-5.1.2'
Making all in include
make[2]: Entering directory `/root/Desktop/varnish-5.1.2/include'
.
.
make[2]: Leaving directory `/root/Desktop/varnish-5.1.2'
make[1]: Leaving directory `/root/Desktop/varnish-5.1.2'
Next install the varnish package using make install command.
[root@linuxhelp varnish-5.1.2]# make install
Making install in include
make[1]: Entering directory `/root/Desktop/varnish-5.1.2/include'
make install-am
.
.
/usr/bin/install -c -m 644 varnishapi.pc ' /usr/local/lib/pkgconfig'
make[2]: Leaving directory `/root/Desktop/varnish-5.1.2'
make[1]: Leaving directory `/root/Desktop/varnish-5.1.2'
The installation of the Varnish is completed. To check the version of the Varnish, run the following command.
[root@linuxhelp varnish-5.1.2]# varnishd -V
varnishd (varnish-5.1.2 revision 6ece695)
Copyright (c) 2006 Verdens Gang AS
Copyright (c) 2006-2015 Varnish Software AS
Next configure the Apache to work with Varnish Cache. Execute the sed command to change port 80 to 8080
[root@linuxhelp varnish-5.1.2]# sed -i " s/Listen 80/Listen 8080/" /etc/httpd/conf/httpd.conf
Now restart the HTTPD service by running the following command.
[root@linuxhelp varnish-5.1.2]# systemctl restart httpd
To start the varnish daemon manually by executing the following command.
[root@linuxhelp varnish-5.1.2]# /usr/local/sbin/varnishd -a :80 -b localhost:8080
Debug: Platform: Linux,3.10.0-123.el7.x86_64,x86_64,-jnone,-smalloc,-smalloc,-hcritbit
Debug: Child (13758) Started
Now you can test the Varnish Cache on Apache by executing the curl command on localhost as follows.
[root@linuxhelp varnish-5.1.2]# curl -I http://localhost
HTTP/1.1 403 Forbidden
Date: Thu, 03 Aug 2017 17:52:38 GMT
Server: Apache/2.4.6 (CentOS)
.
.
Via: 1.1 varnish (Varnish/5.1)
Connection: keep-alive
The installation of Varnish cache on CentOS 7 is done successfully.
Comments ( 0 )
No comments available