Updated Version of this howto
Varnish is a awesome Reverse Proxy, for caching websites and improves its performance in a polish varnish way.
To setup follow the instructions (tested on CentOS
yum update
yum install ncurses-devel
make clean
mkdir /usr/local/src/varnish-2.0.5
mkdir /opt/logs
mkdir /var/lib/varnish
vim /etc/fstab
tmpfs /var/lib/varnish tmpfs nosuid,noatime,nodiratime,size=500M 0 0
cd /
wget http://xoroz.com/files/varnish.zip
unzip varnish
tar -xvf varnish2.tar
chown root:root -R /usr/local/src/varnish-2.0.5
cd /usr/local/src/varnish-2.0.5
make clean
./compile.sh
make && make install
cd /usr/local/
ls -ltr
mv varnish varnish-2.0.5
ln -s varnish-2.0.5/ varnish
(add both varnishd,varnishdncsa files to /etc/init.d/)
vim /etc/sysconfig/iptables
*nat
:PREROUTING ACCEPT [393136:23556287]
:POSTROUTING ACCEPT [24626907:1397282388]
:OUTPUT ACCEPT [24626907:1397282388]
-A PREROUTING -i eth0 -p tcp -m tcp –dport 80 -j REDIRECT –to-port 81
COMMIT
service iptables restart
iptables -t nat -L
( copy varnish and varnish_hour to /etc/logrotate.d both )
edit the crontab
crontab -e
# VARNISH Log Rotation
0-59/5 * * * * [ ! -f /var/run/rotating.pid ] && /usr/sbin/logrotate /etc/logrotate.d/varnish || /usr/local/bin/check_dead_rotating.pid
1 * * * * [ ! -f /var/run/rotating.pid ] && /usr/sbin/logrotate /etc/logrotate.d/varnish_hour || /usr/local/bin/check_dead_rotating.pid
# EOF
(edited 22/07)
Will also need to do:
1. Add the varnish bin to path
PATH=/usr/local/varnish/bin:$PATH
2. install ncurses
yum install ncurses
3. compile varnishstat
cd /usr/local/src/varnish-2.0.5/bin/varnishstat
make all
make install
4. copy to bin
cp /usr/local/src/varnish-2.0.5/bin/varnishstat /usr/local/varnish/bin
5. Run the command:
varnishstat
1 thought on “Howto Setup Varnish”