In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to install and use varnish3.0. The content of the article is of high quality, so the editor will share it for you as a reference. I hope you will have some understanding of the relevant knowledge after reading this article.
Install the latest version of Varnish 3.0 on the vps of the intranet for testing
Varnish has rpm under centos and deb binary package under ubuntu to download, but I chose to compile and install the source code
Download varnish-3.0.0.rar first
Yum install gcc
Yum install gcc-c++ libstdc++-devel
Yum install-y httpd-devel pcre perl pcre-devel zlib zlib-devel GeoIP GeoIP-devel
Varnish requires pcre support, and if the server does not have pcre-devel installed, it will prompt you to specify a prce directory.
Install using yum install pcre-devel on a Centos server
Decompress varnish for compilation and installation
Cd varnish-3.0.0
. / autogen.sh
. / configure-- prefix=/usr/local/varnish PKG_CONFIG_PATH=/usr/lib/pkgconfig
Make
Make install
After the installation is successful, the installation directory is
Cd / usr/local/varnish/sbin
. / varnishd-V
Check the version to see if the installation is successful
Test varnish
Edit the configuration file first
Vi / usr/local/varnish/etc/varnish/default.vcl
Copy the code
The code is as follows:
# This is a basic VCL configuration file for varnish. See the vcl (7)
# man page for details on VCL syntax and semantics.
#
# Default backend definition. Set this to point to your content
# server.
#
Backend default {
.host = "192.168.88.156"
.port = "80"
# New additions to the following three behaviors
.connect _ timeout = 1s
.first _ byte_timeout = 5s
.between _ bytes_timeout = 2s
}
#
# Below is a commented-out copy of the default VCL logic. If you
# redefine any of these subroutines, the built-in logic will be
# appended to your code.
Sub vcl_recv {
If (req.restarts = = 0) {
If (req.http.x-forwarded-for) {
Set req.http.X-Forwarded-For =
Req.http.X-Forwarded-For + "," + client.ip
} else {
Set req.http.X-Forwarded-For = client.ip
}
}
If (req.request! = "GET" & &
Req.request! = "HEAD" & &
Req.request! = "PUT" & &
Req.request! = "POST" & &
Req.request! = "TRACE" & &
Req.request! = "OPTIONS" & &
Req.request! = "DELETE") {
/ * Non-RFC2616 or CONNECT which is weird. , /
Return (pipe)
}
If (req.request! = "GET" & & req.request! = "HEAD") {
/ * We only deal with GET and HEAD by default * /
Return (pass)
}
If (req.http.Authorization | | req.http.Cookie) {
/ * Not cacheable by default * /
Return (pass)
}
Return (lookup)
}
#
Sub vcl_pipe {
# # Note that only the first request to the backend will have
# # X-Forwarded-For set. If you use X-Forwarded-For and want to
# # have it set for all requests, make sure to have:
# # set bereq.http.connection = "close"
# # here. It is not set by default as it might break some broken web
# # applications, like IIS with NTLM authentication.
Return (pipe)
}
#
Sub vcl_pass {
Return (pass)
}
#
Sub vcl_hash {
Hash_data (req.url)
If (req.http.host) {
Hash_data (req.http.host)
} else {
Hash_data (server.ip)
}
Return (hash)
}
#
Sub vcl_hit {
Return (deliver)
}
#
Sub vcl_miss {
Return (fetch)
}
#
Sub vcl_fetch {
If (beresp.ttl
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.