Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install and configure Varnish

2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to install and configure Varnish, the article is very detailed, has a certain reference value, interested friends must read it!

Varnish acts as a web accelerator for accessing web speeds and is installed in front of web servers, thereby caching web server applications and data and finally responding to client requests. The functionality is similar to Squid Server, both of which can be used as HTTP caches.

installation

Install PCRE

If pcre is not installed, when compiling varnish version 2.0 or above, you will be prompted that the pcre library cannot be found. The pcre library is for compatibility with regular expressions, so you must install the pcre library first. Here is how to install PCRE:

[root@varnish-server ~]# tar -zxvf pcre-7.9.tar.gz[root@varnish-server ~]# cd pcre-7.9/[root@varnish-server ~]# ./ config --prefix=/usr/local/pcre/[root@varnish-server ~]# make && make install

Installing Varnish

Here, install Varnish in/usr/local/as follows:

[root@varnish-server ~]# tar -zxvf varnish-2.1.2.tar.gz[root@varnish-server ~]# cd varnish-2.1.2[root@varnish-server ~]# export PKG_CONFIG_PATH=/usr/local/pcre/lib/pkgconfig[root@varnish-server ~]# ./ configuer --prefix=/usr/local/varnish \>--enable-dependency-tracking>--enable-debugging-symbols>--enable-developer-warnings[root@varnish-server ~]# make[root@varnish-server ~]# make install[root@varnish-server ~]# cp redhat/varnish.initrc /etc/init.d/varnish[root@varnish-server ~]# cp redhat/varnish.sysconfig /etc/syscinfug/varnish

Where "PKG_CONFIG_PATH" is the path that specifies Varnish to find the pcre library, and Varnish is installed.

configured

Due to space constraints, here is the introduction of VCL built-in function meaning, please forgive me!

vcl_recv function

Used to accept and process requests. Called when a request arrives and is successfully received, it determines how to process the request by judging the requested data. This function typically ends with the following keywords:

>pass: means to enter pass mode and pass control of the request to the vcl_pass function.> pipe: indicates entering pipe mode, please give control of the request to vcl_pipe function.> error code [reason]: returns a "code" to the client and abandons processing the request.

vcl_pipe function

This function is called when entering pipe mode and is used to pass the request directly to the backend host, returning the same content to the client without changing the request and returned content until the connection is closed. This function typically ends with the following keywords:

>pipe: means to enter pipe mode, please give the request control to vcl_pipe function.> error code [reason]: returns a "code" to the client and abandons processing the request.

vcl_pass function

This function is called when entering pass mode and is used to pass the request directly to the backend host. The backend host sends the reply data to the client after the reply data, but does not cache it, and returns the latest content every time under the current connection. This function typically ends with the following keywords:

>pass。> error code [reason]: returns a "code" to the client and abandons processing the request.

lookup

Means to find the requested object in the cache and pass control to vcl_hit or function vcl_miss depending on the result of the lookup.

vcl_hit function

After the lookup instruction is executed, the function is called automatically when the requested content is found in the cache. This function typically ends with the following keywords:

>pass: means to enter pass mode and pass control of the request to the vcl_pass function.> deliver: means to send the found content to the client and give control to vcl_deliver.> error code [reason]: returns a "code" to the client and abandons processing the request.

vcl_miss function

This method is automatically invoked when the requested content is not found in the cache after the lookup instruction is executed. This function can be used to determine whether content needs to be fetched from a backend server. This function typically ends with the following keywords:

>pass。> fetch: Indicates fetching the requested content from the backend and handing control to vcl_fetch.> error code [reason]: returns a "code" to the client and abandons processing the request.

vcl_fetch function

This method is invoked after the backend host updates the cache and fetches the content, and then determines whether to put the content in the cache or return it directly to the client by judging the fetched content. This function typically ends with the following keywords:

>pass。> deliver: means to send the found content to the client and give control to vcl_deliver.> error code [reason]: returns a "code" to the client and abandons processing the request.

vcl_deliver function

Called before sending the requested content found in the cache to the client. This function typically ends with the following keywords:

>deliver: means to send the found content to the client and give control to vcl_deliver.> error code [reason]: returns a "code" to the client and abandons processing the request.

vcl_timeout function

Call this function before the cache content expires. This function typically ends with the following keywords:

>descard: indicates that the content is cleared from the cache.> fetch

vcl_discard function

This function is called automatically when the cache content expires or when the cache space is insufficient. This function typically ends with the following keywords:

>descard>keep: Indicates that the content remains in the cache. That's all for "How to install and configure Varnish", thanks for reading! Hope to share the content to help everyone, more relevant knowledge, welcome to pay attention to the industry information channel!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report