ubuntu – varnish守护程序不监听已配置的端口

前端之家收集整理的这篇文章主要介绍了ubuntu – varnish守护程序不监听已配置的端口前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试在ubuntu 16.04上安装varnish,

我看过几篇文章都没有.
从我读到的,自ubuntu 15.04以来,配置清漆的方式已经改变(因为systemd).

现在,我有一个真正的混乱,不起作用:

/ etc / default / varnish:

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

/etc/varnish/default.vcl(通常它指向一个指向127.0.0和端口8080的主机,但出于debuging目的我将其修改为外部域)
vcl 4.0;

# Default backend definition. Set this to point to your content server.
backend default {
    .host = "www.varnish-cache.org"; 
    .port = "80";
}

/etc/apache2/ports.conf

Listen 8080

grep -R’ExcStart = /usr/sbin / varnishd’/ etc /

/etc/systemd/system/varnish.service:ExecStart=/usr/sbin/varnishd -j unix,user=vcache -F -a :80 -T localhost:6082 -f /etc/varnish/default.vcl -S /etc/varnish/secret -s malloc,256m
/etc/systemd/system/varnish.service.d/customexec.conf:ExecStart=/usr/sbin/varnishd -a :80 -T localhost:6082 -f /etc/varnish/default.vcl -S /etc/varnish/secret -s malloc,256m
/etc/systemd/system/multi-user.target.wants/varnish.service:ExecStart=/usr/sbin/varnishd -j unix,256m

/lib/systemd/system/varnish.service:

GNU nano 2.5.3                                                Fichier: /lib/systemd/system/varnish.service                                                                                                      

[Unit]
Description=Varnish HTTP accelerator
Documentation=https://www.varnish-cache.org/docs/4.1/ man:varnishd

[Service]
Type=simple
LimitNOFILE=131072
LimitMEMLOCK=82000
ExecStart=/usr/sbin/varnishd -j unix,256m
ExecReload=/usr/share/varnish/reload-vcl
ProtectSystem=full
ProtectHome=true
PrivateTmp=true
PrivateDevices=true

[Install]
WantedBy=multi-user.target

服务–status-all | grep清漆

[ - ]  varnish
 [ + ]  varnishlog
 [ + ]  varnishncsa

之后

sudo service varnish stop
sudo service varnish start

清漆服务没有在http://127.0.0.1:80/上监听,在重新启动之前,它会在http://127.0.0.1:6081/上收听,但它不再工作……我不知道知道该做些什么……

编辑:重启后,没有任何作用,

如果我做 :
systemctl状态清漆

● varnish.service - Varnish HTTP accelerator
   Loaded: loaded (/etc/systemd/system/varnish.service; enabled; vendor preset: enabled)
  Drop-In: /etc/systemd/system/varnish.service.d
           └─customexec.conf
   Active: inactive (dead) since jeu. 2017-01-05 14:48:09 CET; 1s ago
     Docs: https://www.varnish-cache.org/docs/4.1/
           man:varnishd
  Process: 5077 ExecStart=/usr/sbin/varnishd -a :80 -T localhost:6082 -f /etc/varnish/default.vcl -S /etc/varnish/secret -s malloc,256m (code=exited,status=0/SUCCESS)
 Main PID: 5077 (code=exited,status=0/SUCCESS)

janv. 05 14:48:09 xubuntu-16 systemd[1]: Started Varnish HTTP accelerator.

服务–status-all | grep清漆

[ - ]  varnish
 [ - ]  varnishlog
 [ - ]  varnishncsa

如果我sudo:varnishd -d -f /etc/varnish/default.vcl,然后开始,一切正常……直到我退出cli

感谢@Gerald Schneider的回应.我发布了我必须做的步骤:

sudo apt remove varnish
sudo apt-get purge varnish
# I manually remove the 3 files in created in /etc/systemd/system/*
sudo apt install varnish
sudo nano /lib/systemd/system/varnish.service # put the rigth conf
sudo nano /etc/varnish/default.vcl #put the rigth conf
sudo systemctl daemon-reload
sudo service varnish restart

一切正常!
魔术在/lib/systemd/system/varnish.service文件中,我发现的其他在线资源让我认为它在其他地方,所以要小心在线(过时的)教程!

您还需要更改systemd服务定义中的varnish start参数.您可以在服务定义文件中编辑以ExecStart开头的行:
sudo vi /lib/systemd/system/varnish.service

但是,修改文件的缺点是在将来的软件包更新中不会更新.或者,如注释中所建议的那样,您可以创建一个systemd drop in file,这是向systemd定义添加设置的首选方法.

# create the drop in directory
sudo mkdir /etc/systemd/system/varnish.service.d
# create the drop in file. The name is irrelevant,as long as it ends in .conf
sudo vi /etc/systemd/system/varnish.service.d/mysettings.conf

在这里,您只需要添加您想要更改的设置,其他所有内容都将从默认定义文件中加载.

例:

[Service]
ExecStart=/usr/sbin/varnishd -j unix,256m

这是默认行,根据需要进行更改

然后,告诉systemctl重新加载它的配置文件并重启服务

sudo systemctl daemon-reload
sudo service varnish restart

现在,Varnish应该在端口80上收听.

猜你在找的Ubuntu相关文章