How WordPress installs varnish acceleration under CentOS server

Source: Internet
Author: User
Tags bz2 rar zip centos centos server varnish wordpress blog


Varnish is a high-performance open-source HTTP accelerator, Norway's largest online newspaper Verdens Gang (http://www.vg.no) using 3 units varnish replaced the original 12 squid, performance is even better than before. Visible varnish is a rather powerful accelerator. Roy is here to introduce how to install varnish on CentOS to speed up your WordPress blog.



1, install Varnsih



Use SSH to log in to your VPS and execute the following command to install varnish:



Yum Install varnish



And then we start varnish:



/etc/init.d/varnish start



Set to boot:



Chkconfig–level 345 Varnish on



2, configure varnish



Open DEFAULT.VCL:



Nano/etc/varnish/default.vcl



Confirm that the default DEFAULT.VCL matches the following code:



# Back-end Backend default {. Host = "127.0.0.1";. Port = "n";. connect_timeout = 60s;. First_byte_timeout = 10s;. b Etween_bytes_timeout = 10s; } # Custom Sub vcl_recv {remove req.http.x-forwarded-for; set req.http.x-forwarded-for = Client.ip; if (req.url ~ "^/wp-" ( login|admin) "") {return (pipe);} if (Req.http.Cookie ~ "(wp-postpass|wordpress_logged_in|comment_author_)") {return ( Pipe); } if (req.request = "POST") {return (pass),} if (Req.http.cache-control ~ "No-cache") {return (pass);} if (Req.http.a Uthorization) {return (pass);} if (Req.url ~). ( JPG|JPEG|GIF|PNG|ICO|CSS|ZIP|TGZ|GZ|RAR|BZ2|PD f|txt|tar|wav|bmp|rtf|js|flv|swf|htm|html) $ ") {unset Req.http.Cookie; Unset req.http.accept-encoding; Unset req.http.Vary; return (lookup); } if (req.http.accept-encoding) {if (Req.url ~). ( Jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg) $ ") {remove req.http.accept-encoding;} elsif (req.http.accept-encoding ~" gzip ") { Set req.http.accept-encoding = "gzip"; } elsif (req.http.accept-encoding ~ "Deflate") {Set req.http.accept-encoding = "deflate";} else {remove req.http.accept-encoding;}} if (req.backend.healthy) {Set req.grace = 30s;} else {set req.grace = 1h;} unset Req.http.Cookie; Unset req.http.Vary; return (lookup); Sub Vcl_fetch {Set beresp.grace = 1h; unset beresp.http.set-cookie; if (req.url ~). JPG|JPEG|GIF|PNG|ICO|CSS|ZIP|TGZ|GZ|RAR|BZ2|PD f|txt|tar|wav|bmp|rtf|js|flv|swf|htm|html) $ ") {set beresp.ttl = 24h;} else {Set beresp.ttl = 5m;} return (deliver); Sub Vcl_deliver {if (obj.hits > 0) {Set resp.http.x-cache = ' HIT ';} else {Set resp.http.x-cache = ' MISS ';} set re Sp.http.cache-control = "private"; Set resp.http.Pragma = "Private"; Remove Resp.http.x-varnish; Remove Resp.http.Via; Remove Resp.http.Age; Remove Resp.http.Server; Remove resp.http.x-powered-by; Sub Vcl_pipe {Set bereq.http.connection = ' close '; Restart varnish to take effect:/etc/init.d/varnish restart

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.