Here are the steps to install and configure Varnish cache on Ubuntu 16.04 LTS:
- Install Varnish:
sudo apt-get update
sudo apt-get install varnish
- Edit the default Varnish configuration:
sudo nano /etc/default/varnish
- Change the
DAEMON_OPTS
variable to listen on port 80:
DAEMON_OPTS="-a :80 \
-T localhost:6082 \
-f /etc/varnish/default.vcl \
-S /etc/varnish/secret \
-s malloc,256m"
- Configure Varnish to use a backend server:
sudo nano /etc/varnish/default.vcl
- Replace the contents of the file with the following:
backend default {
.host = "127.0.0.1";
.port = "8080";
}
- Replace
127.0.0.1
with the IP address of your backend server, and replace8080
with the port number of your backend server.
- Restart Varnish:
sudo service varnish restart
- Test Varnish by sending a request to the Varnish cache on port 80:
curl http://localhost
If the request returns a response from the backend server, Varnish is working correctly.
Note: These instructions are a basic guide for setting up Varnish. You may need to make additional configuration changes based on your specific requirements.