在Ubuntu(15.10)上运行LEMP,尝试添加清漆,遇到问题

我似乎有varnish问题。 这不是什么大问题,但我正在努力寻找可能会出错的地方。

基本上, varnish被设置为在6081端口上运行; 然而。 我已经尝试编辑/etc/default/varnishconfiguration,并将daemon_opts更改为80 ,甚至评论 – 文件中的所有内容,但清漆似乎仍然在6081运行。

所以要么不使用/etc/default/varnishconfiguration,要么在其他地方获取它的设置,要么/etc/default/varnish没有任何区别。

我的问题是没有人知道它可能使用什么configuration文件来获得它的设置,或者我怎么能强制它使用configuration? 谢谢。

想象一下修正,因为这是一个与清漆的错误。 这篇文章的其余部分是这篇文章的编辑版本: http : //deshack.net/how-to-varnish-listen-port-80-systemd/


基本上, /etc/default/varnish只能由/etc/init.d/varnish script读取,而不能由systemd初始化脚本( /lib/systemd/system/varnish.service/lib/systemd/system/varnish.service

我们可以覆盖varnish的systemd初始化脚本并改变一些东西。

 # cp /lib/systemd/system/varnish.service /etc/systemd/system/ # nano /etc/systemd/system/varnish.service 

我们拿出这样的东西:

 [Unit] Description=Varnish HTTP accelerator [Service] Type=forking LimitNOFILE=131072 LimitMEMLOCK=82000 ExecStartPre=/usr/sbin/varnishd -C -f /etc/varnish/default.vcl ExecStart=/usr/sbin/varnishd -a :6081 -T localhost:6082 -f /etc/varnish/default.vcl -S /etc/varnish/secret -s malloc,256m ExecReload=/usr/share/varnish/reload-vcl [Install] WantedBy=multi-user.target ExecStart=/usr/sbin/varnishd -a :80 -T localhost:6082 -f /etc/varnish/default.vcl -S /etc/varnish/secret -s malloc,256m 

然后使用,

 # sudo service varnish restart 

要么

 # systemctl reload varnish.service 

确保你使用了正确的DAEMON_OPTS行。 默认的Varnishconfiguration有4个DAEMON_OPTSconfiguration的例子(scheme1,最小configuration;scheme2,configurationVCL;等等)。 如果您取消注释了其中的几个,则仅应用最后一个未注释的DAEMON_OPTS行。

例:

 ## Alternative 2, Configuration with VCL # # Listen on port 6081, administration on localhost:6082, and forward to # one content server selected by the vcl file, based on the request. # Use a 256MB memory based cache. # DAEMON_OPTS="-a :80 \ -T localhost:6082 \ -f /etc/varnish/default.vcl.v4 \ -S /etc/varnish/secret \ -s malloc,256m"