Varnish is a website acceleration (reverse proxy, cache server). Varnish can be used to achieve static and dynamic separation of the site, load balancing, page caching, request filtering (simple anti-collection, etc.).
Varnish official website: https://www.varnish-cache.org/
Installation version: Varnish Cache 4.0.3
: https://www.varnish-cache.org/content/varnish-cache-403
Note: Varnish sites can sometimes be wall-
Git Download:
git clone https://github.com/varnish/Varnish-Cache/var/tmp/
Dependency: Address: https://www.varnish-cache.org/docs/4.0/installation/install.html
The Linux version is: Debian/ubuntu
Dependency Package: Red does not install, and Yum does not seem to exist
Automake
Autotools-dev
Libedit-dev
Libjemalloc-dev
Libncurses-dev
Libpcre3-dev
Libtool
Pkg-config
Python-docutils
Python-sphinx
The Linux version is: Red Hat/centos
Dependency Package: Red does not install, and Yum does not seem to exist
Autoconf
Automake
Jemalloc-devel
Libedit-devel
Libtool
Ncurses-devel
Pcre-devel
Pkgconfig
Python-docutils
Python-sphinx
Partial missing Packet error./configure Compilation Status:
Configure:error:no acceptable C compiler found in $PATHSee ' Config.log ' for more details
Missing GCC class compilation tool
Configure:error:rst2man is needed to build Varnish, please install python-docutils.
Missing python-docutils
Configure:error:requires an x/open-compatible Curses library
Missing Ncurses-devel
Checking for PCRE ... noconfigure:error:Package requirements (libpcre) were not met:no package ' libpcre ' Foundconsider ad Justing the PKG_CONFIG_PATH environment variable if youinstalled software in a non-standard prefix. Alternatively, you may set the environment variables Pcre_cflagsand pcre_libs to avoid the need-to-call pkg-config. See the Pkg-config Mans page for more details.
Missing Pcre-devel
Configure:error:neither Libedit nor another ReadLine compatible library found
Missing Libedit-devel
Section./autogen.sh Error Status:
./autogen.sh:line 29:automake:command not foundwarning:unable to determine Automake version
Missing automake,autoconf (These two packages are installed together using Yum)
+ libtoolize--copy--force./autogen.sh:line 44:libtoolize:command not found
Missing Libtool
Download:
wget https://repo.varnish-cache.org/source/varnish-4.0.3.tar.gz
Extract:
TAR-ZXVF varnish-4.0.3.tar.gz
Enter the unzip directory to compile the installation:
./autogen.sh If you download an installation package from a git library, you need to run it to generate configure compiled files.
./configure --prefix=/var/varnish/ Specify the installation directory, optional
Make
Make install
Copy the VCL file (in the compiled installation directory) if there is no DEFAULT.VCL file in the installation directory.
Copy to the var/varnish/directory of the installation directory (of course, there is no need to ask in which directory, because you will have to specify the directory for this file at the time of the official boot)
CP ETC/EXAMPLE.VCL/VAR/VARNISH/VAR/VARNISH/DEFAULT.VCL
Go to the installation directory
Edit the copied vcl file (if you want to modify the steering port number or host address, the default port number is 8080), otherwise skip.
VI VAR/VARNISH/DEFAULT.VCL
Modify the lower steering port
Backend default {. Host = "127.0.0.1"; . Port = "8080";}
If you have Apache installed or nginx has to be shut down and modify the listening port to 8080 (set the same as the varnish steering port), then launch Apache or Nginx.
Start varnish (note that the port number cannot be occupied)
Sbin/varnishd-f var/varnish/default.vcl-s malloc,1g-t 127.0.0.1:2000-a 0.0.0.0:80
Open Browse input address: 127.0.0.1 or localhost
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/6C/19/wKioL1VAPgjDYZZRAAQNIoSpDFY267.jpg "title=" Qq20150429100600.jpg "alt=" Wkiol1vapgjdyzzraaqniospdfy267.jpg "/>
./sbin/varnishd Start Parameter Description:
Official address: https://www.varnish-cache.org/docs/4.0/reference/varnishd.html
-A address[:p ort][-a address[:p ort][...]
Listens for client requests for the specified address and port. The address can be a hostname ("localhost"), a IPv4 point divided into four groups ("127.0.0.1"), or a IPv6 address ("[:: 1]") enclosed in square brackets. If no address is specified, Varnishd listens to all available IPv4 and IPV6 interfaces. If no ports are specified, such as the use of the default HTTP port/service listed in/etc. Multiple listening addresses and ports are available. If a local address is specified, it can only be accessed locally.
-B host[:p ORT]
Use the specified host as the back-end server. If no port is specified, the default is 8080. The backend command in a VCL file like-F can specify a reverse ingress address and port, but only one can be specified. is a quick start mode. Cannot exist with-F at the same time
-C
Print compiled into C language and exit VCL code. Specifies that VCL file compilation uses the-F option.
-D
Enable Debug mode: The parent process runs on the foreground of a CLI connection with the standard input/output, and the child processes must be explicitly started using CLI commands. Terminating the parent process also terminates the child.
-F Config
Replaces the built-in default values with the specified VCL configuration file. Cannot exist with-B at the same time, but must specify one, otherwise the service cannot start
-F
Running at the current terminal will occupy the current terminal operator interface.
-G Group
Specifies the name of a non-privileged group that the child process should switch to before it begins accepting connections. This is a shortcut for specifying the run-time parameters for the group.
-H Type[,options]
The specified hash algorithm. Hash list type, and length. The default length is 16383.
-I. Identity
Specifies the identity of the server. This can be accessed by using server.identity from VCL
-L Shl[,free[,fill]]
Specifies the size of the Shmlog file. SHL is a shared memory log (default 80M), free is an idle space, and fill is already used space. The memory size can be set to ' K ', ' M ' and so on.
-M Address:port
Connect to this port and provide a command line interface. Think of it as a reverse shell. When you run with-M, the backend (cache) of the child processes that are not defined will fail to start initially.
-N Name
The temporary file instance name. If you start with "/", you must be an available path.
-P File
Writes the PID of the process to the specified file.
-P Param=value
The set parameter is specified as the specified value, see the parameter list for the run-time parameter. This option can be used multiple times to specify multiple parameters.
-R Param[,param ...]
Makes the listed parameters read-only. Used to protect parameters. See parameter list for run-time parameters.
-S [name=]type[,options]
There are three ways to cache settings:
Malloc[,size] (memory +swap swap mode)
File[,path[,size[,granularity]] (file form)
Persistent,path,size (File form)
malloc (malloc) acquires memory through malloc, simple, fast
Mmap File Cache
This is a two-way varnish cache, which can be specified by parameters at startup.
The granularity is used to set the cache space allocation unit, which is the default unit of bytes, and all other sizes will be rounded.
The size is the specified amount of space, which can be g,m,k and so on.
Path is the file directory
-T address[:p ORT]
Manager Port. CLI ingress address and port, use the talnet command to access the CLI interface Management Server, or you can use the Varnishadm
-T TTL
Specifies the cache file. This is a shortcut for specifying the Default_ttl run-time parameters.
-U user
Specifies the name of a non-privileged user that the child process should switch to before accepting the connection. This is a shortcut to the specified user run-time parameter.
If users and groups are specified at the same time, the user should first specify.
-V
Displays the version number and exits.
Stop varnish
Pkill varnishd (Kill the process directly, only use the command above to start varnish)
Or
Varnishadm Stop (need to go to the installation directory of the bin directory, just shut down the child process, you can use Varnishadm start to open the service again or use the above start command)
This article is from the "gangbusters" blog, make sure to keep this source http://php2012web.blog.51cto.com/5585213/1640182
Linux under Varnsih4 installation