Apache2
Dynamic and static page for testing for example Wordpress
sudoedit /etc/default/varnish
Step one. Install Varnish
sudo apt-get install varnish
Step two. Configure Varnish
Look for lines that are not commented in "Alternative 2" and change DAEMON_OPTS to port 80.
Save that file and exit after two port changes. You can check if default.vcl file is set correctly. Default port should be 8080, if not change it to 8080.
Step three. Configure Apache.
We told Varnish to listen port 8080 but Apache default is set to 80 so we have to change that. Change to both virtual and listen 8080.
And as always after making changes, kick the demons.
sudo service varnish restart
Now open your browser and type localhost to see if your setup is working correctly. If not you can try changing all * marks from setting files to 127.0.0.1
Testing Varnish
First stop your Varnish
sudo service varnish stop
Apache benchmark your Wordpress
ab -n100 -c100 http://localhost:8080/~shnigi/wordpress/
As you can see it is not very fast. Then start Varnish again
sudo service varnish restart
And do the same test again but not in the port 8080
ab -n100 -c100 http://localhost/~shnigi/wordpress/
And as you can see Varnish + Apache is a lot faster than without Varnish! Static page is an advantage. Remember to check that commenting and other dynamic things work normally.
Source: https://www.digitalocean.com/community/articles/how-to-install-and-configure-varnish-with-apache-on-ubuntu-12-04--3
INFO: Varnish doesn't work on RaspberryPi out of the box. If you somehow mess your Varnish setup and want to return Apache to port 80 you may need to check what program is blocking port 80. Probably Varnish at this point. Use: sudo netstat -tulpn| grep :80 to find out what is blocking that port and then kill it: pkill varnish
INFO: Varnish doesn't work on RaspberryPi out of the box. If you somehow mess your Varnish setup and want to return Apache to port 80 you may need to check what program is blocking port 80. Probably Varnish at this point. Use: sudo netstat -tulpn| grep :80 to find out what is blocking that port and then kill it: pkill varnish
Ei kommentteja:
Lähetä kommentti