linux環境下安裝varnish
阿新 • • 發佈:2018-03-29
在線 max-age sam 加速器 char 導出 mct localhost ubuntu
Varnish是一款高性能的開源HTTP加速器,挪威最大的在線報紙 Verdens Gang 使用3臺Varnish代替了原來的12臺Squid,性能比以前更好。
sudo apt-get install varnish -y
首先,刪除/etc/varnish/default.vcl文件並從導出的Varnish配置創建一個符號鏈接:
sudo rm -rf /etc/varnish/default.vcl
sudo ln -s /var/www/html/magento/var/varnish.vcl /etc/varnish/default.vcl
接下來,您將需要為Varnish創建一個systemd服務文件。 您可以將varnish.service從/ lib / systemd / system /復制到/ etc / systemd / system /目錄中:
sudo cp /lib/systemd/system/varnish.service /etc/systemd/system/
復制該文件後,您將需要對varnish.service文件進行一些更改:
sudo nano /etc/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,user=vcache -F -a :80 -T localhost:6082 -f /etc/varnish/default.vcl -S /etc/varnish/secret -s malloc,256m ExecReload=/usr/share/varnish/reload-vcl ProtectSystem=full ProtectHome=true PrivateTmp=true PrivateDevices=true [Install] WantedBy=multi-user.target
完成後保存文件,然後使用以下命令重新啟動Varnish服務:
sudo systemctl daemon-reload
sudo systemctl reload varnish.service
如果一切正常,那麽您應該能夠通過在Web瀏覽器上輸入以下URL來登錄到Magento後端:
http://192.168.15.189/admin_wczta4
您還可以通過運行以下命令來檢查是否啟用了Varnish:
curl -I http://192.168.15.189/admin_wczta4
您應該看到Varnish已啟用:
Date: Fri, 07 Jul 2017 17:10:01 GMT Server: Apache/2.4.18 (Ubuntu) Set-Cookie: store=default; expires=Sat, 07-Jul-2018 17:10:03 GMT; Max-Age=31536000; path=/; HttpOnly Set-Cookie: PHPSESSID=irp2k8cmrhct0dfh18qk7ap0i4; expires=Fri, 07-Jul-2017 18:10:04 GMT; Max-Age=3600; path=/; domain=192.168.15.189; HttpOnly Expires: Thu, 07 Jul 2016 17:10:04 GMT Cache-Control: max-age=0, must-revalidate, no-cache, no-store Pragma: no-cache Location: http://192.168.15.189/admin_wczta4/?SID=irp2k8cmrhct0dfh18qk7ap0i4 X-Content-Type-Options: nosniff X-XSS-Protection: 1; mode=block X-Frame-Options: SAMEORIGIN Content-Length: 0 Content-Type: text/html; charset=UTF-8 X-Varnish: 2 Age: 0 Via: 1.1 varnish-v4 Connection: keep-alive
linux環境下安裝varnish