国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
Varnish+Nginx搭建緩存服務(wù)器
一. varnish
1.安裝pcre庫,兼容正則表達(dá)式
# tar -zxvf pcre-8.10.tar.gz
# cd pcre-8.10
# ./configure --prefix=/usr/local/pcre
# make && make install
2.配置安裝varnish
# tar -zxvf varnish-3.0.2.tar.gz
# cd varnish-3.0.2
# export PKG_CONFIG_PATH=/usr/local/pcre/lib/pkgconfig/
# ./configure --prefix=/usr/local/varnish
# make && make install
3.修改varnish配置文件
/usr/local/varnish/etc/varnish/default.vcl
# mv default.vcl default.vcl.bak
# vi cq.vcl
backend cqserver {
.host = "127.0.0.1";
.port = "8087";
.connect_timeout = 20s;
}
acl purge {
"localhost";
"127.0.0.1";
"192.168.1.0"/24;
}
sub vcl_recv {
if(req.request == "PURGE") {
if(!client.ip ~ purge) {
error 405 "Not allowed.";
}
return(lookup);
}
if(req.http.host ~ "^www.baidu.com") {
setreq.backend = cqserver;
if(req.request != "GET"&& req.request != "HEAD") {
return(pipe);
}
else{
return(lookup);
}
}
else{
error 404 "caoqing Cache Server";
return(lookup);
}
}
sub vcl_hit {
if(req.request == "PURGE") {
setobj.ttl = 0s;
error 200 "Purged.";
}
}
sub vcl_miss {
if(req.request == "PURGE") {
error 404 "Not in cache.";
}
}
(1)Varnish通過反向代理請求后端IP為127.0.0.1,端口為8087的web服務(wù)器,即nginx服務(wù)器監(jiān)聽端口;
(2)Varnish允許localhost、127.0.0.1、192.168.1.*三個(gè)來源IP通過PURGE方法清除緩存;
(3)Varnish對(duì)域名為www.baidu.com的請求進(jìn)行處理,非www.baidu.com域名的請求則返回"caoqing Cache Server";
(4)Varnish對(duì)HTTP協(xié)議中的GET、HEAD請求進(jìn)行緩存,對(duì)POST請求透過,讓其直接訪問后端Web服務(wù)器。
4.啟動(dòng)varnish
# cd /usr/local/varnish/sbin/
# ./varnishd -f /usr/local/varnish/etc/varnish/cq.vcl -s file,/var/varnish_cache,1G -T 127.0.0.1:2000 -a 0.0.0.0:80
二. nginx
1.安裝nginx
# rpm -ivh zlib-devel-1.2.3-4.el5.i386.rpm
# tar zxvf nginx-1.4.1.tar.gz
# cd nginx-1.4.1
# ./configure --prefix=/usr/local/nginx --with-openssl=/usr/lib --with-pcre=/root/tool/pcre-8.10 --with-http_stub_status_module
# make && make install
2.啟動(dòng)nginx
# cd /usr/local/nginx/sbin
# ./nginx
3.修改ngnix配置文件
測試配置文件/usr/local/nginx/sbin/./nginx-t
# cd /usr/local/nginx/conf
# vi nginx.conf
#使用的用戶和組
user  root root;
#制定工作衍生進(jìn)程數(shù)(一般為CPU總核數(shù)兩倍)
worker_processes  8;
#制定文件描述符數(shù)量
worker_rlimit_nofile 51200;
#指定錯(cuò)誤日志存放路徑
error_log  logs/error.log
#指定pid存放路徑
pid        logs/nginx.pid;
event
{   
#使用網(wǎng)絡(luò)I/O模型
     use epoll;
#允許的連接數(shù)
     worker_connections  65535;
}
http {
#訪問日志存放路徑
    access_log logs/access.log;
#開啟gzip壓縮
    gzip            on;
    gzip_min_length  1000;
    gzip_proxied     expired no-cache no-store private auth;
    gzip_types       text/plaintext/csstext/xmltext/javascriptapplication/x-javascriptapplication/xmlapplication/rss+xml application/xhtml+xml application/atom_xml;
    gzip_disable "MSIE [1-6].(?!.*SV1)";
#限定PHP-CGI的連接、發(fā)送和讀取的時(shí)間為300s
    fastcgi_connect_timeout 300s;
    fastcgi_send_timeout 300s;
    fastcgi_read_timeout 300s;
#虛擬主機(jī)配置
server {
#監(jiān)聽端口
       listen 8087;
#主機(jī)名稱
       server_name 127.0.0.1;
#google提供的DNS服務(wù)
       resolver 8.8.8.8
       location / {
#nginx作為HTTP代理服務(wù)器
            proxy_pass http://$http_host$request_uri;
            proxy_set_header Accept-Encoding '';
            proxy_redirect          off;
       }
}
}
三. 排錯(cuò)優(yōu)化
1)修改環(huán)境變量
vi~/.bashrc
PATH=$PATH:/usr/local/nginx/sbin:/usr/local/varnish/sbin/usr/local/varnish/bin
exportPATH
2)nginx啟動(dòng)與關(guān)閉
參數(shù):
-v:查看版本
-V:查看配置模塊
-t:查看配置文件是否正確
-c:制定其他配置文件
pkill -9 nginx
3)varnish啟動(dòng)與關(guān)閉
參數(shù):
-u:以什么用戶運(yùn)行
-g:以什么組運(yùn)行
-f:varnish配置文件
-a:綁定IP和端口
-s:varnish緩存位置和大小
-w:最小,最大線程和超時(shí)時(shí)間
-T:varnish管理端口,主要用來清除緩存
pkill varnishd
varnish服務(wù)動(dòng)態(tài)加載配置文件
#varnishadm -T 127.0.0.1:2000
vcl.load vcl-name_vcl "配置文件路徑"# vcl-name 這里可以任意取名
vcl.use vcl-name
vcl.show vcl-name #顯示vcl-name配置文件內(nèi)容
# varnishncsa -w /usr/local/varnish/logs/varnish.log
將輸出日志寫入到制定日志文件。
4)修改windows客戶端
C:\Windows\System32\drivers\etc\hosts
192.168.1.202 www.baidu.com
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
使用Varnish代替Squid做網(wǎng)站緩存加速器的詳細(xì)解決方案
使用Nginx的proxy_cache緩存取代Varnish
使用Nginx反向代理和proxy
nginx+tomcat的安裝配置
3、單機(jī)運(yùn)行環(huán)境搭建之 --CentOS 安裝tengine
Tengine動(dòng)態(tài)模塊擴(kuò)展
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服