varnish简明教程

2009-05-13 12:04:46来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折


操作步骤
cd
useradd -d /dev/null -s /sbin/nologin
[url=javascript:;]varnish[/url]
wget
http://nchc.dl.sourceforge.net/sourceforge/varnish/varnish-1.1.1.tar.gz
tar zxvf varnish-1.1.1.tar.gz
cd varnish-1.1.1
./configure --prefix=/usr/local/varnish
[url=javascript:;]make[/url]
make install
cd /usr/local/varnish
mkdir var
mkdir logs
mkdir etc
mkdir cache
touch /usr/local/varnish/etc/cache.vcl
touch /usr/local/varnish/stopv
touch /usr/local/varnish/startv
touch /usr/local/varnish/resetv
chmod +x /usr/local/varnish/stopv
chmod +x /usr/local/varnish/startv
chmod +x /usr/local/varnish/resetv
cd ..
chown -R varnish varnish
chgrp -R varnish varnish

逐步说明
增加一个varnish帐户
useradd -d /dev/null -s /sbin/nologin varnish
下载varnish
wget
http://nchc.dl.sourceforge.net/sourceforge/varnish/varnish-1.1.1.tar.gz
解压
tar zxvf varnish-1.1.1.tar.gz
cd varnish-1.1.1
配置
./configure --prefix=/usr/local/varnish
编译
make
[url=javascript:;]安装[/url]
make install
设置相关目录
cd /usr/local/varnish
mkdir var
mkdir logs
mkdir etc
mkdir cache
配置文件
touch /usr/local/varnish/etc/cache.vcl
touch /usr/local/varnish/stopv
touch /usr/local/varnish/startv
touch /usr/local/varnish/resetv
chmod +x /usr/local/varnish/stopv
chmod +x /usr/local/varnish/startv
chmod +x /usr/local/varnish/resetv
修改
[url=javascript:;]权限[/url]
cd ..
chown -R varnish varnish
chgrp -R varnish varnish
cache.vcl内容
backend www1 {
    set backend.host = "后端真实的web IP1";
    set backend.port = "http";
}

backend www2 {
    set backend.host = "后端真实的web IP2";
    set backend.port = "http";
}

backend www3 {
    set backend.host = "后端真实的web IP2";
    set backend.port = "8080";
}
#可以做多个类似的后端

acl purge {
                 "localhost";
                 "后端真实的web IP1";
                 "后端真实的web IP2";
         }
        
sub vcl_recv {
   
    if (req.http.host ~ "域名1") {
        set req.backend = www1;

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:Samba 文件服务器用户复杂权限模型设计和实现

下一篇:varnish cache 配置使用