国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > CentOS > 正文

WordPress在CentOS服務器下如何安裝Varnish加速

2020-05-27 13:10:38
字體:
來源:轉載
供稿:網友

  Varnish是一款高性能的開源HTTP加速器,挪威最大的在線報紙Verdens Gang (http://www.vg.no) 使用3臺Varnish代替了原來的12臺squid,性能居然比以前更好。可見Varnish是一個相當強大的加速器。下面羅伊給大家介紹如何在 CentOS上安裝Varnish來給你的WordPress博客加速。

  1,安裝Varnsih

  使用SSH登錄你的VPS,執(zhí)行下面的命令來安裝Varnish:

  yum install varnish

  然后我們啟動Varnish:

  /etc/init.d/varnish start

  設置為開機啟動:

  chkconfig –level 345 varnish on

  2,配置Varnish

  打開default.vcl:

  nano /etc/varnish/default.vcl

  確認默認的default.vcl和下面的代碼相匹配:

  # Back-End backend default { .host = "127.0.0.1"; .port = "80"; .connect_timeout = 60s; .first_byte_timeout = 10s; .between_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.Authorization) { 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 resp.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"; } 重啟Varnish使其生效: /etc/init.d/varnish restart

 

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 宜春市| 唐海县| 浑源县| 嵊泗县| 崇阳县| 明光市| 襄城县| 调兵山市| 夏河县| 文昌市| 阿拉善盟| 平武县| 通榆县| 奉新县| 高青县| 马公市| 洱源县| 眉山市| 聂荣县| 荥阳市| 卓尼县| 区。| 长顺县| 台山市| 海伦市| 荥经县| 绥芬河市| 灵璧县| 泗水县| 同心县| 根河市| 台南市| 环江| 垦利县| 屯留县| 锡林浩特市| 灵山县| 尚志市| 沙湾县| 齐河县| 嘉峪关市|