14y, 13d ago
[edited]
Implementing Varnish Cache
Install varnish
sudo apt-get install varnish
Make varnish listen to port
80
Also disable the varnish admin port
sudo cp -p /etc/default/varnish /etc/default/varnish.ORIG
sudo vim /etc/default/varnish
diff /etc/default/varnish /etc/default/varnish.ORIG
40c40,41
< DAEMON_OPTS="-a :80 \
---
> DAEMON_OPTS="-a :6081 \
> -T localhost:6082 \
Make Apache2 vhosts
listen to port 8080
cp -p /etc/apache2/ports.conf /etc/apache2/ports.conf.ORIG
sudo vim /etc/apache2/ports.conf
diff /etc/apache2/ports.conf /etc/apache2/ports.conf.ORIG
8c8
< NameVirtualHost *:8080
---
> NameVirtualHost *:80
10c10
< Listen 8080
---
> Listen 80
Now edit all the vhost files with two commands:
cd /etc/apache2/sites-available
sudo perl -pi -w -e 's/\:80/\:8080/g;' *
The above command performs a search and replace on every file in the
directory changing :80 to :8080
Restart Daemons
sudo service apache2 restart
sudo service varnish restart
Comments