专注于magento建站与magento二次开发
提供magento教程 magento模板 magento插件

ubuntu 16.04 安装Varnish 5 并配置magento2

 

 

curl -L https://packagecloud.io/varnishcache/varnish5/gpgkey | sudo apt-key add –
sudo apt update
sudo apt install -y apt-transport-https

 

vi /etc/apt/sources.list.d/varnishcache_varnish5.list

编辑源

deb https://packagecloud.io/varnishcache/varnish5/ubuntu/ xenial main
deb-src https://packagecloud.io/varnishcache/varnish5/ubuntu/ xenial main

 

sudo apt update

 

sudo apt install varnish

 

查看是否安装成功

varnishd -V

 

配置Varnish

sudo rm -f /etc/varnish/default.vcl

sudo ln -sf /var/www/magento2/var/varnish.vcl /etc/varnish/default.vcl

sudo mkdir -p /etc/systemd/system/varnish.service.d

sudo nano /etc/systemd/system/varnish.service.d/customexec.conf

复制以下内容

[Service]
ExecStart=
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

 

重启

sudo systemctl daemon-reload

配置magento2的nginx配置文件

vim /etc/nginx/sites-available/magento2

 

sudo rm -rf /etc/varnish/default.vcl

sudo ln -s /var/www/magento2/var/varnish.vcl /etc/varnish/default.vcl

 

sudo cp /lib/systemd/system/varnish.service /etc/systemd/system/

vim /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配置参考

https://wiki.mikejung.biz/Varnish

https://www.varnish-software.com/wiki/content/tutorials/magento2/index.html

https://cloudkul.com/blog/configure-varnish-and-redis-magento-2/    安装redis 和 varnish

How to Deploy Magento 2 on CentOS 7 with ECS and ApsaraDB

https://www.alibabacloud.com/blog/How-to-Deploy-Magento-2-on-CentOS-7-with-ECS-and-ApsaraDB_p292700

https://blog.hauri.me/magento-2-with-varnish-and-nginx-as-ssl-termination.html

Install & Configure Varnish Cache for Magento 2

https://github.com/fballiano/docker-magento2/blob/master/varnish.vcl

赞(0) 打赏
未经允许不得转载:magento建站专家 - magento4you » ubuntu 16.04 安装Varnish 5 并配置magento2
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

magento建站magento二次开发联系QQ283475615

联系我们立即咨询

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏