有关Varnish文档中此步骤的说明

时间:2012-02-10 23:54:22

标签: apache caching varnish

步骤:https://www.varnish-cache.org/docs/3.0/tutorial/putting_varnish_on_port_80.html

这是我的单一步骤:

1)pkill varnishd (完成!)

2)编辑Web服务器的配置,并将其绑定到端口8080而不是80“

这一步是什么意思?我使用Apache

3)default.vcl并将默认后端的端口更改为8080 (完成!)

4)varnishd -f /usr/local/etc/varnish/default.vcl -s malloc,1G -T 127.0.0.1:2000 (完成!)

Varnish不起作用,因为我跳过了第3步。我必须在那做什么?解释一步......

PS:什么是比Varnish更简单的替代品?

2 个答案:

答案 0 :(得分:1)

我认为Varnish和Apache都是从同一台机器提供的,因为你需要更换端口。标准的www端口是80.您希望Varnish为该端口提供服务,并将请求转发给将在另一个端口上运行的Apache(8080)。

我不经常配置Apache的端口,但我认为以下描述应该有效。编辑httpd.conf文件(通常位于“/etc/httpd/conf/httpd.conf”中)并将端口设置从“端口80”更改为“端口8080”,然后重新启动apache。如果存在,您可能还必须将“Listen 80”更改为“Listen 8080”。

答案 1 :(得分:1)

如果您使用的是Debian,请遵循以下说明:

  1. 停止清漆:sudo /etc/init.d/apache2 stop

  2. 停止Apache:sudo /etc/init.d/varnish stop

  3. /etc/apache2/ports.confListen 80更改为Listen 8080

  4. 将所有虚拟主机更新为端口8080,/etc/apache2/sites-available/*<VirtualHost xxxxxxxxxxx:80>更改为<VirtualHost xxxxxxx*:8080>

  5. /etc/default/varnish中更改以下代码:

    DAEMON_OPTS =“ - a:6081 \              -T localhost:6082 \              -f /etc/varnish/default.vcl \              -S / etc / varnish / secret \              -s malloc,256m“

  6. 通过以下

    DAEMON_OPTS="-a :8080 \                     <======== THIS LINE
                 -T localhost:6082 \
                 -f /etc/varnish/default.vcl \
                 -S /etc/varnish/secret \
                 -s malloc,256m"
    

    /etc/varnish/default.vcl中使用以下代码声明您的后端:

    backend default {
        .host = "127.0.0.1";
        .port = "8080";
    }
    
    1. 启动Apache:sudo /etc/init.d/apache2 start

    2. 开始清漆:sudo /etc/init.d/varnish start