Install Varnish with Nginx Web Server Ubuntu 16.04 LTS
Install Varnish with Nginx Web Server Ubuntu 16.04 LTS
– Install Nginx from the Ubuntu repository by using the apt-get command to server.
sudo apt-get update sudo apt install nginx -y
When the Nginx installation is complete the next step is to start Nginx and enable it for startup every time at system boot by using the systemctl commands given below.
sudo systemctl start nginx sudo systemctl enable nginx
Now time to Check Nginx which port is working on it. Nginx/Apache, etc web server default port is port 80.
netstat -ntlup | grep nginx
After check Nginx port then you need to change Nginx port which we are going to standard port 80 to non-standard port 8080.
cd /etc/nginx/sites-available vim default
Now you should change default port of Nginx.
Change 'listen' line value 80 listen 80 default_server; listen [::]:80 default_server ipv6only=off; # If you have require IPv6 then on it
TO
Change 'listen' line value 8080. listen 8080 default_server; listen [::]:8080 default_server ipv6only=off; # If you have require IPv6 then on it
Save the File and exit from it.
After that Check nginx config file and you should restart nginx service.
nginx -t sudo systemctl restart nginx
After restarting the nginx server then again check port.
netstat -ntlup | grep nginx
nginx is working on the port 8080.
– Install Varnish on Ubuntu 16.04 LTS
sudo apt-get update sudo apt-get install varnish
When we have installed Varnish on machine then we required to enable service and restart.
sudo systemctl start varnish.service sudo systemctl enable varnish.service
Then enable service we are change to Varnish port.
vim /etc/varnish/default.vcl
backend default { .host = "127.0.0.1"; .port = "8080"; }
Now you can do Save and exit…
Now Varnish need to set port 80.
vim /etc/default/varnish
Check on the file ‘DAEMON_OPTS’ line and default port is 6081. So we need to change this 6081 port to port 80.
Note: Varnish consume memory 256m, you can change as per requirement.
DAEMON_OPTS="-a :80 -T localhost:6082 -f /etc/varnish/default.vcl -S /etc/varnish/secret -s malloc,256m"
Do Save and exit…
Reload the system config daemon and restart your Varnish service.
sudo systemctl daemon-reload sudo systemctl restart varnish sudo service php7.1-fpm restart
Wonderful Job!!!!!
Again Check Varnish do creating stats or not.
varnishstat
You should also check with terminal.
crul -I http://domain-name
OR
Note: Find to how to get Lifetime free SSL Certificate for domain
For more detail : Varnish Cache