Question

I follow this steps. (https://magemastery.net/blog/how-to-configure-varnish-6-and-nginx-with-ssl-for-magento-2) I install vanish and nginx complete. Now i export default.vcl from magento2 and set value on that file.

backend default { .host = "127.0.0.1"; .port = "8080"; }

and i can run this command complete. mv /etc/varnish/default.vcl /etc/varnish/default.vcl.BACK

But I don't understand. The steps say "Now upload default.vcl which was downloaded from your magento admin panel".

How to upload default.vcl from my pc to ssh. and about edit ExecStart. Please guide me about it. This is my first time working with command. I don't understand for upload, edit and save file.

Thank you very much.

Was it helpful?

Solution

Logging in via SSH

The first thing you need to do is gain access to the system via ssh.

  • If you're on Windows you'll have to download PuTTY.
  • If you're a Mac user, you can use the Terminal app to run ssh

The SSH protocol runs over port 22 and gaining access happens either via username & password, or via an SSH key.

Here's an example where you use the ssh binary on the command line to gain access to the example.com server via the user user.

ssh user@example.com

If a valid SSH private key was configured on your computer, and a valid public key was configured on the server, you will get access to the server without providing a password. If that's not the case, you will be prompted for a password

Placing the VCL in the right place

Once you're on the system, you have to place your VCL file in the right directory.

The tutorial you mentioned uses the following command to make sure you have a backup of your original VCL file:

mv /etc/varnish/default.vcl /etc/varnish/default.vcl.BACK

There are various was to put the new VCL content in /etc/varnish/default.vcl. You can use local editors such as vi or nano. You can also transfer content from your computer to the server via scp.

The scp binary is just like the ssh binary: it takes the same credentials, it uses the same protocol. scp is designed to transfer files from your local system to the server.

Here's an example command:

scp /path/to/vcl/default.vcl user@example.com:/etc/varnish/default.vcl

This command will take the VCL file that is in /path/to/vcl/default.vcl on your local computer, and will send it to /etc/varnish/default.vcl on the server.

If you're a Windows user, you can also use WinSCP to drag and drop your VCL file to the right folder.

Modifying systemd ExecStart settings

If you want to change some of the runtime parameters, you can do this by running the following command:

sudo systemctl edit --full  varnish

Your tutorial mentions this as well, and uses it to change the listening port.

There are plenty of other options you can configure. See http://varnish-cache.org/docs/6.4/reference/varnishd.html#http-accelerator-daemon for a complete overview.

Reloading the configuration

Once the correct VCL file is in the right place and the systemd settings are updated, you have to reload Varnish. But if you changed systemd, you also need to reload the systemd daemon.

Just to be on the safe side, please run the following 2 commands:

sudo systemctl daemon-reload
sudo systemctl restart varnish
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top